I am uploading an image via Amazon SDK to S3. Those PNG images are optimized using ImageMagick ASP.NET library. The problem is that I can see them fine when optimized on my computer (testing locally), but when uploaded to S3, they are being heavily distorted. Do you know what can be the cause for this?
I am using ASP.net. I thought that the reason for that is that the image haven't been completely saved, but that no seems to be a good option because the file should have been locked and couldn't be streamed.
Here, take a look..
http://i1182.photobucket.com/albums/x448/dphotowriter/2011-09-07_002928.png
I did a test. When I upload the image directly to Amazon via AWS it is fine. The problem lies somewhere between saving the image and the moment it is streams. Maybe is asynchronous and the image hasn't finished to be written completely and then uploaded only part of it.
I tried to put:
System.Threading.Thread.Sleep(5000);
after the optimization to but it didn't help either. Maybe it something to do with the STREAM for that PNG files. I do the following:
1) Save the image to a temp.png file.
2) Read the file to an image object
3) convert the file to byte array
4) pass the byte array to the MemoryStream constructor
Related
Situation
I'm trying to use my own images in the Tensorflow Style Transfer demo, but they're causing the following error message:
InvalidArgumentError: Unknown image file format. One of JPEG, PNG, GIF, BMP required. [Op:DecodeImage]
What I've tried
The error message says the file format must be a JPEG among other file types. When I check the file info, it says Kind: JPEG image, and the file extension is .jpg.
The image was shot on a Google Pixel 6 Pro, pulled directly from Google Photos, and then uploaded directly to my GCS Bucket. So I can't understand how there could be a problem with the file format, or what to check for to resolve this.
I've also tried several links to the same GCS object.
https://storage.cloud.google.com/01_bucket-02/PXL_20220315_232045529.PORTRAIT.jpg
gs://01_bucket-02/PXL_20220315_232045529.PORTRAIT.jpg
But I'm getting the same error message with both.
I'm able to view the images in a browser window, so my authentication should be ok.
Causing further confusion, I downloaded one of the wikimedia images used in the demo, then immediately uploaded it to my GCS bucket, and it caused the same error message. The Wikimedia file was .jpg, but when I downloaded it, the extension was .jpeg.
This is the original Wikimedia file I was testing:
https://upload.wikimedia.org/wikipedia/commons/d/d7/Green_Sea_Turtle_grazing_seagrass.jpg
Any clarification on what might be going on with this would be greatly appreciated.
Doug
There is any possibility to upload a file with different sizes in DropzoneJs?
I'm using vue-dropzone which is made with dropzonejs and i have to upload the same file with different sizing for srcset.
Example:
I want to upload the file test.png which is 1000x500 px. There is any possibility to upload it at the same time in original resolution and also in 500x250px?
Image resizing in the browser has been a seat-of-the pants experience for a long time. Web assemblies are the way of the future for processing-intensive tasks in web apps. I came across this project the other day. It looks fantastic and I really can't wait to strip out our home-baked image resizing with canvas and replace it with this.
The usual reason for doing this is to avoid large uploads. It's a little bit weird to want to resize in the browser then upload the original. You might be better resizing on the server. You'll save bandwidth and the server libraries will be more mature than what's available on the client.
Along with the original image object you can add one more your custom resized image to the array of images by using resize config of dropzone. You can do the above on drop event or adddedFile event of dropzone.
With phantomjs you can choose the file format to use for page.render().
I'm finding that the file size I'm getting for png is around three times higher than what I'm getting for gif. I wasn't aware that png should be any worse (in terms of file size) than gif; in fact I thought png was meant to be better.
Unfortunately, I kinda need to output to png because of its support for variable opacity, but the larger file size is a bit of an issue.
So, is there any way in which I can control file size of the png? Maybe change the encoding scheme or something? I'm currently using phantomjs 1.9.8.
Inside of PhantomJS
No, there is no way to make the png file size smaller, but there is a way to make it bigger (just for fun):
Render the file to png,
load the file to a canvas of appropriate size,
get the Data-URI of the canvas in png or any other format,
decode the Base 64 part and write to file (this is very tricky to get right).
PhantomJS 1.x has a bug which results in a vastly inflated, but valid file.
Only jpeg rendering enables you to specify a quality setting which will result in a smaller file size, but then again jpeg doesn't support transparency.
You could also see whether PhantomJS 2.0.0 behaves better, because it has an engine underneath it that is almost three years newer than in PhantomJS 1.x.
Outside of PhantomJS
Your best bet would be to render the png in PhantomJS as-is and post-process it with your favorite library. It may even be enough to open it and save it again.
You can for example call an installed program with the child process module or your can open a webpage that contains such a service and upload the captured file or base64 representation of it. The possibilities are endless.
I'm evaluating Fine Uploader compared to various other options, specifically JQuery File Upload.
I generally prefer the Fine Uploader approach as it's more lightweight, compared to JQuery File Uploader which has dependencies on Bootstrap and JQuery UI.
However it's important to be able to resize images: e.g., a user may select a large file from their camera and this may be very large - uploading the full resolution photo may take a very long time. JQuery File Upload doe this.
Additionally we don't have much use for very high resolution files.
If possible (I'm aware some browsers may not support this), I'd like to be able to resize images client size.
Is this possible?
Fine Uploader does not currently have any native support for image manipulation. This is a feature in our backlog, but we have not had many users tell us they are interested in this. This is one of the reasons why such a feature has yet to be implemented natively. There is a case, #707 that marks the start of native image-editing support for Fine Uploader. It is tentatively scheduled for 4.0.
However, you can certainly make use of FileReader and Canvas to resize the image. You can then submit this resized image as a Blob to Fine Uploader via the addFiles API method. At that point, the file has been submitted and Fine Uploader is ready to upload the item.
Essentially, the steps you would follow to handle this specific scenario, before Fine Uploader natively supports image manipulation:
Provide your own file input element(s) or make use of Fine Uploader's file/folder drag and drop support to get a handle on some files selected by the user.
Use FileReader to read the contents of the image.
FileReader will provide you with a URL for the image, assign that to the src attribute of an img element.
Draw the img onto a canvas element. This is where the resizing occurs.
Grab the URL of the resized image from the canvas element (canvas.toDataURL(...)).
Convert the URL to a Blob.
Pass the Blob to the addFiles API method of Fine Uploader.
The intent is to take care of most if not all of this for integrators such as yourself in the future by adding native image manipulation support to Fine Uploader.
Hope this helps.
I'm trying to read JPEG2000 images in Magick++ (the C++ API of ImageMagick). To read an image I use the following code:
Image img("path/to/my/image.jp2");
But when I try to do this, ImageMagick throws an Exception and doesn´t load the image.
I extract the images out of PDF files. Could it be that something´s different to normal JPEG2000 images? To extract the images I read the stream of Image objects which have a JPXDecode-filter and save them to a file.
Hope someone can help me!
ImageMagick uses a package called JasPer to handle JPEG2000's. According to the wikipedia page on OpenJpeg, JasPer does not completely support the JPEG2000 specification. I have several extrected JPEG2000 that open fine in QuickTime, but fail to decode with ImageMagick.
I have had better results using OpenJpeg to decode the the Jpeg2000. The interface is less flexible, it will convert to PNG and BMP.