Image version on Carrierwave - ruby-on-rails

I'm making an album section and after the user uploads the images, carrierwave is making some versions like :thumb and :full.
When showing all the albums I get the first image of the album and display as the album cover. The thing is, I'm having to resize the thumb image and it gets ugly, I'd like to know if I can make a version (:cover) only of the first image uploaded so I can call this version when showing albums, but only the first image, so I don't have to make this version for all the images since I'll just be using the first one.

Related

Carrierwave - crop image before upload?

I am trying to implement image cropping into my rails app. I watched this railscast https://www.youtube.com/watch?v=ltoPZEzmtJA but it looks like the file is uploaded then it brings you to another page to crop. Is it possible to crop the image before uploading it, or at least do it all at the same time?

YTPlayerView thumbnail custom size

I am using YTPlayerView library from Google. I want to get the customised size thumbnail of a youtube video for my iOS app.
Can anybody help me how I can achieve this? Current it is giving me the same size thumbnail for a video regardless of the size of my YTPlayerView.
YTPlayerView.load automatically loads its own thumbnail. However, a workaround could be you place a UIImageView on top of the YTPlayerview. And load the customized thumbnail into that UIImageview. You can start playing the video when the UIImageview is clicked using YTplayerview.play. And then hide the thumbnail. In essence, it would give the effect the video is being played upon clicking your customised thumbnail image. You may have to fine-tune some things to make this solution work elegantly.
To retrieve the image for the customised thumbnail, you can use any of 4 generated images of youtube. They are predictably formatted as follows:
https://img.youtube.com/vi/<insert-youtube-video-id-here>/0.jpg
https://img.youtube.com/vi/<insert-youtube-video-id-here>/1.jpg
https://img.youtube.com/vi/<insert-youtube-video-id-here>/2.jpg
https://img.youtube.com/vi/<insert-youtube-video-id-here>/3.jpg
The first one in the list is a full size image and others are thumbnail images. The default thumbnail image (ie. one of 1.jpg, 2.jpg, 3.jpg) is:
https://img.youtube.com/vi/<insert-youtube-video-id-here>/default.jpg
For the high quality version of the thumbnail use a url similar to this:
https://img.youtube.com/vi/<insert-youtube-video-id-here>/hqdefault.jpg
I hope this helps to answer your question.

Paperclip - Wrong image orientation

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

Is it possible to restyle a picture after getting uploaded in paperclip?

if pictures are uploaded using one style, how can i change the style of the uploaded picture after the picture is already uploaded. say if i want to change from tiny or thumb to original?
Thanks,
If you specified for example two styles :thumb and :grid and uploaded image to it, then you already have three images by default: grid, thumb and original. So in your views you could just use <your attachment>.path(:thumb) or <your attachment>.path(:grid).
Anyway if you added some more styles to your model you should call rake paperclip:refresh:missing_styles.
Documentation

How to save cropped image of an image URL without saving the original image? (in Rails using Paperclip or other plug-ins)

Hi all
I have an app now showing photos from URL, not from my own database (file system).
For example, a photo from Facebook:
http://sphotos.ak.fbcdn.net/hphotos-ak-snc1/hs085.snc1/5041_98423808305_40796308305_1960517_6704612_n.jpg
I've added the crop function to get the cropping area (x,y,w,h) of the photo.
And now I'd like to save the cropped image from the URL (i.e. without downloading the original image to my database before cropping)
Is it even possible?
Or is there anyway to get the image into memory to process without saving it to database?
I've searched some questions here, but they all talk about how to save the crop of images which have been uploaded to the database by users.
Thank you very much in advance.
How do you imagine cropping works without access to the original image? The process would be like this:
Download the remote image to a /tmp as a temporary file (Tip: TempFile)
Crop the crap out of it
Save the cropped image with Paperclip to your DB
Remove the temporary file

Resources