How to check the file format on an image to run through Tensorflow style transfer demo - tensorflow

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

Related

Generating preview image thumbnails of uploaded files on Rails

I'm using Rails to create a website that allows users to upload document files with various file formats (pdf, doc, docx, ppt, pptx, xls, xlsx, png, jpg, jpeg) and store them on aws S3.
I'm using Carrierwave to directly upload files to S3, and everything works well so far. Uploaded files are nicely stored in S3.
But now, I want to display preview images (thumbnail images) for uploaded files. I've tried several different methods by manipulating Carrierwave configuration, but it seems like generating thumbnail images only works on PDF files, not other file formats. Can anyone please give me any insight to make this work? Thanks
Rather than generating thumbnails within the application, you could consider using systems that can generate thumbnails on-the-fly, such as:
Cloudinary
Imgix
This link might help you:
http://guides.railsgirls.com/thumbnails
I also found a tutorial that says you should be able to uncomment some code in the image_uploader file.
version :thumb do
process :resize_to_fill => [50, 50]
end
https://code.tutsplus.com/tutorials/rails-image-upload-using-carrierwave-in-a-rails-app--cms-25183
See if either of these solutions work.
As John wrote, for your images you can try generating thumbnails on the fly with a solution like Cloudinary's jQuery image upload library. This solution enables image uploading to the cloud. Uploaded images are stored safely in the cloud with secure backups and revision history, utilizing Amazon's S3 service.
Cloudinary's jQuery library also enables on the fly generation of thumbnails.
Here is a sample code that creates a 150x100 thumbnail of an uploaded image and updates an input field with the public ID of this image.
$('.cloudinary-fileupload').bind('cloudinarydone', function(e, data) {
$('.preview').html(
$.cloudinary.image(data.result.public_id,
{ format: data.result.format, version: data.result.version,
crop: 'fill', width: 150, height: 100 })
);
$('.image_public_id').val(data.result.public_id);
return true;
});
Here you can find some Ruby on Rails examples

Adding a pdf file instead of an image in the joomla mediamanager

I would like to add a pdf file to the joomla media manager, and then select it as a full article image, so that I can get the link using json and echo it for every product, without having to manually add a pdf link every time.
However when I want to link the pdf file to an article, and browse to the folder where the pdf file is located, it says: 'No images found'.
Is it possible to add pdf files to an article instead of an image, using the media manager?
This is where I browse to my pdf file:
https://i.gyazo.com/8ef91fc2d1ea26a36abcfb22bcc0cd25.png
Hello #twan,
I can see only solution to your question is : PDF Embed Plugin from Techjoomla
Try using this extension and let me know if it works for you or not.
Thanks,
Mrunal.

Google Drive's html to Docs document conversion corrupted since 2 Oct

We have been using Google Drive SDK for our app.
Since 2 October, when our app tries to create a Google Docs native document by uploading a html file contains img tags, the result become partly corrupted. Although the upload request finishes without error, all the images in the html are lost in the created document.
The behavior is not usual. For nearly two years, basically, the conversion for document insertion had interpreted the img tags and created embedded images. It seems like a server side problem exists.
Is it a known issue and would be fixed?
Or, is there something I'm missing and it is correct behavior?
[About the htmls we use]
The htmls for upload are based on exported "text/html" files from existing Google Docs documents.
All the img tags have src attribute with absolute url. They start with https and all of them are links on googleusercontent.com.
Apart from the img tags, all the html tags seems to be handled as before.
[How to reproduce the problem]
This problem can be reproduced by using DriveSample app in "Google APIs Client Library for Objective-C". Modify "DriveSampleWindowController.m" to force document conversion turned on (i.e., query.convert=YES;) just before uploading a file to Drive.
Download an existing Docs document with images as html.
Upload it as a new document to Google Drive (with document conversion turned on).
Open the uploaded document in 2 with Google Docs web editor. All images would be lost in the document. Also, no spinning wheels will be shown for the lost image areas.
The problem seems fixed on the server side within the last half day. Thank you for fixing it, Google.

Distorted images after uploading to S3 (optimized with ImageMagick)

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

Magick++ - Reading JPEG2000 images

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.