Paperclip - Wrong image orientation - ruby-on-rails

I'm using Paperclip 4.1.1 for images uploading. I store three sizes, original, medium and thumbnail. When I try to show the original images, some of them appear rotated to the left, and it happens randomly, because some others are displayed correctly. This does not happen with medium and thumbnail sizes. The funny fact is that if I open any original image url on a browser, it always displays correctly. Any thoughts?
EDIT:
According to this comment in the Paperclip Railscast, this behavior doesn't occur on processed images. As a workaround, I added a new Paperclip style big enough to meet my requirements.

Check this How to set Paperclip to process original image? this will help.
Adding original: {convert_options: '-strip'} in styles help

Related

Strange glowing effect on PDF image assets in iOS?

I am having an issue where the images are rendered with a strange glowing effect around them, pictured here:
It is tough to see from this close but is extremely noticeable when viewing the app. Also, taking these screenshots into a design program and using the color dropper will prove that there is a glow around these images. Each of these images are PDF files, rendered as a template image so that I can change the tintColor instead of adding more images to my assets folder for each color.
I have read some other articles and questions that says there isn't full support for vector graphics yet (here). However, that is outdated as it specifies iOS 7 as the latest version at the time of writing. Now in iOS 13, I assume there have been changes. Another article I read said to never use vector graphics as they can get messed up when Xcode generates PNGs from the PDFs (here).
Information about the assets in my Images.xcassets:
Render as: Template Image
Resizing: Preserve Vector Data
Scales: Single Scale
I also tried to implement 3 PNGs at different sizes (#1x, #2x, #3x) for each image but got the same effect.
Creating new images with a smaller border size got rid of the glow but obviously, that doesn't fit the design style style that I want in an app. I designed these Icons in Sketch and used a border size of 3, then exported as PDF.
So, as I was writing this question I seemed to have found an answer.
It turns out it had nothing to do with anything in Xcode. The problem lies with Sketch. I redesigned each element in Adobe Illustrator, exported them as PDFs, set the same settings in the assets folder like so:
Render as: Template Image
Resizing: Preserve Vector Data
Scales: Single Scale
Here are the updated screenshots:
I am using:
Sketch (Version 52.5)
Adobe Illustrator (Version 24.2.1)
I don't know why this is an issue, but I hope it can help someone who has this issue down the road. If anyone has any more information on this, please write a comment :).

How can I maintain a high res image in my Storyboard in Xcode without having it pixelate?

I'm making an app using Swift in Xcode. I have a few buttons and images on one of my View Controllers. I am using high resolution images, but I noticed that they pixelate to the point where it is visible to the naked eye. There are some questions that I have found pertaining to the resizing of images, but none regarding immediate pixelization. I was hoping someone could help. Below are two images. The first is an image (a screenshot) from my app and the second is an image (also a screenshot) from another app that is not mine. The icon on the other app is smaller, but despite this is less pixelated.
have you tried using svg instead of jpg (lossy) or png(lossless)? It would seem that this would be the way to go, since you can expand to perfect definition on all resizing screens. svg uses code instead of an image format that can be lossy and given the examples you have posted would solve your issue.
you can use paint code for more easy worked , with paint code you can export svg
I figured it out. I just had to increase the dpi

rails paperclip creating thumb image with smaller image

I am using paperclip in rails to create different size images as follows
has_attached_file :upload,styles: { medium: ["500x300>",:jpg], thumb: ["150x100>",:jpg] }
Ill show my original image and also created thumbnail image here for better understanding
My original image is this
My thumb image created is
I am unable to understand what is happening but this works fine with large size images. What wrong happens here. How to correct it.
From the ImageMagick docs:
Use > to shrink an image only if its dimension(s) are larger
than the corresponding width and/or height arguments.
As a result, your original 256x256 image won't create your medium size, which defines 500x300
I'm not sure if this has anything do with your problem, but I guess that the sizes and operators messed up something. I bet that playing around with other arguments, such as ! and ^ will do.

Need advice on image resizing and display for Rails app

I'll start by explaining what I would like to do.
I have an image gallery grid layout page with thumbnails. Each thumbnail image is to be the same size, say 120px x 80px. I would like to display all the images on page load and more as a user scrolls down on the page. There will be hover and click states for individual images in the grid where the full size image pops up to display in a lightbox.
What solutions (gems, techniques, etc.) are there for loading images that are larger (1024 x 768) into my database (Photo) model such that I can generate a small thumbnail image of predefined smaller size?
Is the best way to load a whole page of small images if my goal is to allow more to load as the user scrolls down on the page? Or should I load only what the user sees, then use AJAX to load more as they scroll down?
Is Paperclip a common solution in this case? I'm looking into this and CarrierWave on RailsCasts.
If using something like Paperclip, can it handle cropping an image that isn't the same aspect ratio as others? ie, scale and crop a square image the same as a rectangle image to a defined size.
I'm new to handling a large number of images in a rails application and appreciate any advice, books, tutorials, techniques people are familiar with out there.
Thanks!
1) I prefer paperclip, though this may be due to less experience with other gems.
2) Generally, the best way to handle lots of images on a page is with sprite sheets. If the images on the page are always going to be the same, this might be a good option. If you are doing something with infinite scrolling, ajax is the way to go (railscast on infinite scrolling)
3) I'm not sure if paperclip is a common solution, but it certainly is one that you should consider.
4) Yes, cropping works in paperclip.

Calculate thumbnail sizes with RMagick

I'm using attachment_fu and RMagick to upload/resize images on a rails app. Currently I use the local file system as the storage but I have a plan to use AWS S3 for the job. Anyway I am quite interested to know what other peoples' experiences on using S3 and also I have a one big question for you. In my app when a user uploads an image I resize this image to 5 different sizes and store them along with the original images. (altogether 6 images) based on thumbnail sizes provied in the model:
:thumbnails => {
"thumb" => "120x80",
"extra_small"=>"480x320",
"small"=>"640x480",
"medium" => "800x533",
"large"=>"2738x1825",
"extra_large" => "3464x2309"
Finally I get:
image_foo.jpg (Original Image)
image_foo_thumb.jpg
image_foo_extra_small.jpg
image_foo_small.jpg
image_foo_medium.jpg
image_foo_large.jpg
image_foo_extra_large.jpg
The reason why I re-size these images is I need the actual sizes of each image to be stored in the database. But actually even I specified the sizes for thumbnails I don't get the exact sizes. Anyway its OK, as the size is calculated based on the aspect ratio.
But I really don't like to waste the space on the server if I can calculate the thumbnails sizes without saving them to the file system. In other words, I only need to store the original file not the thumbnails, but still I need to get the sizes of the thumbnails. Is it possible to get the actual thumbnail sizes without creating them in RMagick?
Space on S3 is relatively cheap. So I wouldn't worry too much.
However, you could consider converting the images to fewer sizes. You could leave small and extra-small out and use the width and height attributes of the HTML img tag. However, that will make your side load slower and cause more traffic.
I guess what you are really looking for is a solution that converts the files on the fly when they are requested right? I am not sure if there is a solution for that off the shelf. However, this would be a major performance suck.
So my recommendation is to just stick with all the different sizes and pay a few cent more to amazon. This will yield best performance and will be easiest to maintain. You don't have to worry about scaling and the fact that storage is getting cheaper and cheaper works for this solution.

Resources