Imageresizser - how do I save a resized image to a file? - jcrop

I'm using Imageresizer and jCrop to crop an uploaded file which I then put the url (shown below) back into the ImageUrl of an asp:image.
That all works fine but then I need to save that image back to the server - I can't find anything on this so I suspect the answer is very simple
/images/gallery/_temp/5_large.jpg?crop=(160,73,322,235)&cropxunits=480&cropyunits=320&width=600&height=600&scale=both

So, if you want to save it to the same server, you'll need to use C# -
ImageBuilder.Current.Build("~/images/gallery/_temp/5_large.jpg", "target_image.jpg", new Instructions("?crop=(160,73,322,235)&cropxunits=480&cropyunits=320&width=600&height=600&scale=both"));
Or, if you want to save it elsewhere, just save the HTTP response.

Related

Get TinyMCE 4.3 Image Tools to save images as regular image files

The new TinyMCE 4.3 Image Tools (eg when cropping) saves images as blob data instead of image files in a directory. the edited mage url is like
blob:http://www.example.com/f2953aa1-e64f-49e1-a6e3-a283986663bf
I want to upload the image file to a specific folder and then use it as regular image referance / path.
Note
The question I am going to put is similar to Image edit issue. but the answer to this question is not working. I also tried http://archive.tinymce.com/forum/viewtopic.php?id=35740 solution but not working because it produces always same name image name.
The basic process is that TinyMCE will create a separate HTTP POST for each image that you modify with the image editor. It will send that image to a URL of your choosing (via HTTP POST) based on the setting of the images_upload_url option in your init.
The image handler at the URL referenced in the images_upload_url (which you have to create) has to do whatever needs to be done to "store" the image in your application. That could mean something like:
Store the item in a folder on your web server
Store the item in a database
Store the item in an asset management system
...regardless of where you choose to store the image your image handler needs to return a single line of JSON telling TinyMCE the new location of the image. As referenced in the TinyMCE documentation this might look like:
{ location : '/uploaded/image/path/image.png' }
TinyMCE will then update the image's src attribute to the value you return. If you use the images_upload_base_path setting in the init that will be prepended to the returned location. The TinyMCE page has more details on all of this:
https://www.tinymce.com/docs/advanced/handle-async-image-uploads/
The net here is that TinyMCE knows when an embedded image exists in your content but it can't possibly know what to do with that image in the context of your application so that job (the "image handler") is something you must create.

Flex - Download asset to local

I've got an interactive presentation, and it's all working as it should.
Now I want to add a function to download the currently visible image/video.
Because this presentation has a lot of files (all stored under assets/...) and it's a pain to navigate through the assets, I want an easy way to just click a button and get a "Save as.." window.
I've managed to get the url of the media, so now I just need a way to show a "save as.." dialog to allow the users to save/download the file and save it locally.
This whole presentation should be put online, so all the files are located somewhere in the /assets/.. folder inside the project.
Any ideas of how to do this? =)
Thanks!
EDIT #1:
For now I'm using "navigateToURL" to open a new browser window with the media. This works, but is there a way to show a "Save as.." dialog instead of opening the image?
Or any other ways to do this? =)
You are looking for the FileReference class, in particular the FileReference.save( data:*,defaultFileName:String = null ) method. That will open up a "Save..." dialog to save the corresponding data object and allow you to set a default file name. I'm unsure if this class can also handle the download as I have never had a time when I needed to prompt to save something that was to be downloaded. If it cannot handle it, you'll need to look into the URLStream class. That can handle the download and either on ProgressEvent.PROGRESS or Event.COMPLETE, you simply do a URLStream.readBytes( byteArray ); to save the downloaded bytes to a ByteArray and then that is the data object you save. I would look into the FileReference class, though. Odds are it can handle downloads as well.

Wordpress image name same as page

Friends, i'm stuccoed with images in wordpress - please, help me understand where search for solution.
If you create webpage - www.wordpress.local/page1/01-0001 and you upload an image 01-0001 on that page, you can see, that when you'll visit www.wordpress.local/page1/01-0001, you'll see the page with image, not the page, that you created with text and images.
Any ideas how to solve it ?
PS Not renaming images :)
When you use the WordPress-uploader, the images are stored in /wp-content/uploads/, and WordPress takes care of using filenames that aren't already in use.
If you upload an image, e.g. via FTP, that has the same name as a WordPress-page, the server has to decide what it should serve; either the WordPress-page or the image. One URL = one file served.
In your case, the server decides for the image. You could of course change this configuration; but in all cases, one of the two files won't be accessible.
If you want to make both files accessible, you either need to rename the image or the WordPress-page.

How do I rotate an Image in .NET?

I have an asp.net 2010 project. I write a jpg to the filesystem. Then I display it in an Image control. Then I use this code on button click to allow the user to rotate it 90 degrees.
string path = Server.MapPath(Image1.ImageUrl) ;
// creating image from the image url
System.Drawing.Image i = System.Drawing.Image.FromFile(path);
// rotate Image 90' Degree
i.RotateFlip(RotateFlipType.Rotate90FlipXY);
// save it to its actual path
i.Save(path);
// release Image File
i.Dispose();
It does rotate (I can actually watch that happen in Windows Explorer). But when I run the app again and it grabs the file from its path, it still displays it in its original form.
Try adding a dummy querystring to the end of the image like "image1.jpv?v=1". This works to prevent caching for things like Javascript files and it may do the same for you.
This is the classic issue with browser-cached resource files. Alison's answer is one option. Another option is to change the name of the physical file. If you "version" the files, then after each change, the file name will be different. This does mean that you'll have to dynamically reference the image path so that you display the correct version, and you'll need some way to determine the file name for the current version. It does prevent the browser from displaying the previously cached file immediately after a change, though, because it's technically a new file to the browser at that point.
If you are using some sort of data source (XML files or database) to store metadata for the images, then you can add a "Version" column and store a simple integer. With each change, increment the integer value and use the new value in the file name. You can even extend this by saving the previous versions and allowing your users to "undo" actions by copying an older version of the file into a new version. This might require a more robust metadata storage implementation, though.

ASP.NET Refresh the page after uploading image

I have an ASPX page where I am uploading an image to server for on a serverside button click event. In my page, it will show the available image if it exists. When I upload an image, it will replace the old one with the new one. Now after uploading also the same image is getting displayed. How can tackle this? I used window.location.reload() javascript function to refresh, but then it is not working. It is posting the page again.
This is my code
Do UploadImage(studentId,mode); // Function to upload image
StringBuilder sbc = new StringBuilder();
sbc.Append("<script language='javascript'>");
sbc.Append("alert('Upload process completed successfully!');");
sbc.Append("window.location.reload()");
sbc.Append("</script>");
HttpContext.Current.Response.Write(sbc);
It's being cached in the browser. To overcome this - alter the url of the image. This can be done by including a timestamp, version number, or guid in the image file name.
Your browser is probably caching the image. Either disable caching on the image or set up proper caching responses.
You can reload from the server side
Response.Redirect(Request.URL)
A useful tool to debug this is fiddler. As others already suggested it's likely that the browser caches the old version of the image. If you are using IIS you can change the cache policy so that the browser always check for a newer version of the image.

Resources