Prawn image on amazon image not found - ruby-on-rails-3

I am using Prawn 0.12.0 in a Rails 3.2.12 app.
If I have an image on my local server it can show in a standard rails view, and I can also have it shown in a Prawn PDF using the following code
#logo = company.logo_url(:large).to_s
image #logo, :fit => [83.mm, 26.mm]
So far, so good. If I change the location of the image to be on Amazon S3 I get the following
I am able to show in a standard Rails view no problem
If I try to display the image in a Prawn pdf I get the following error
Argument error (https://mydomain.s3.amazonaws.com/uploads/company/logo/20/large_2275_logo.png not found):
And if I then copy and paste that url into a browser, the image shows fine.
So to recap...
I am able to use the Prawn image command for a local image, indicating I am using the Prawn syntax correctly
I can access an image on Amazon S3 using a direct browser and a Rails view, indicating that the URL is correct
BUT, I can not access the image on Amazon S3 from Prawn
Has anyone seen anything similar, or have any suggestions?
Michael

I had the same problem, I've solved with
require 'open-uri'
image open("hxxp://www.thesite.com/theimage.png")

With the recent releases of Prawn, you can achieve loading remote images without requiring open-uri;
image open("http://example.com/remote_image.pdf"), at: [300, 100], width: 100, height: 100

Related

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

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

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

Binary is not optimized for iPhone 5 error message for Xcode 6.3

I've read a number of similar Q&As regarding this subject but none have provided me with a working solution.
All my images are PNG.
My deployment target is 8.3 for iPhone.
I'm using Xcode 6.3
I am using an image catalog.
I've tried using -568h in the image name and tried not using it. I tried changing the filename to "Default-568h#2x.png".
I've deleted all images from the image catalog and dragged them back in again.
I've created a new launch images catalog.
No mater what I've done, the same error message appears when I attempt to upload to the App Store:
EDIT:
On the off chance that lacking iPad launch images might have triggered this issue, I also added all launch images for iPad. I also renamed all the image file names, created a new launch image catalog (again) and imported all images. Still getting the same error message.
Resolved the issue but not sure on the exact reason behind it.
The Launch Screen File field had LaunchScreen selected.
The correct selection should have been Main.
This solved the issue and I was able to submit the app without the error message.

Symfony2 : Resizing uploaded images

Is there any way to resize pictures while uploading them in Symfony2 ?
The ImagineAvalancheBundle only allows to resize images to thumbnails when retrieving them, which is not really performant to me.
Besides, the UploadedFile object retreived when posting data doesn't seems to have resizing methods...
Any Idea ?
I had the same problem you are asking for.
The main issue is that the bundle resizes and/or crops the images directly.
So that can take a lot of time with big images and if many images are expected per page.
So I've fix this issue by calling directly after imageupload the resize() function to the image.
Hence, I save (copy) the resized image to the filesystem at the server. Obviously I store the path of the image into the database to can load it directly if needed.
I tried the included memcache of the imageresize bundle but in my case it doesn't work.
I had the same problem for a project that i'm actually developing. I searched a lot on the net and found nothing realy performant and also easy to use for non-tech people.
I created a bundle to be able to upload with jquery file upload and crop with jcrop with some other functions.
ComurImageBundle
What is exactly your goal ? Resize and crop ? Other ?
I don't understand why you say that the bundle resize to thumbnail only as you can define precisely your resize preset through config :
# app/config/config.yml
avalanche_imagine:
filters:
my_thumb:
type: thumbnail
options: { size: [120, 90], mode: outbound }

rails 3 saving default image while uploading using paperclip

i use paperclip to upload images to the server in rails 3. If the user didn't choose any file to upload i want to store a default image in the server i.e., storing a default image in different size like thumb, normal, feature...
:default_url => '/images/:attachment/missing_:style.png'
I already put the above line in the config/initialize folder.
But for my popup slider i use jAlert in that i use js(to read the image from the server) and db(to get the object id) to show the images. So if an id didn't have any image then no folder(thumb, normal,...) are created.
For that reason i want to store default image for id which didn't have image.
My basic need is to make image slider in a popup window.
Thanks,
Arivarasan L