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?
Related
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.
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
Im using jCrop with Rails 3.2.14 to crop images following the ever popular Railscast from Ryan - http://railscasts.com/episodes/182-cropping-images.
This works 100%, EXCEPT when I try to crop a photo that I already cropped. The problem appears to be that the paperclip processors only apply the processing to the original image but do NOT convert that original image, so when I try to recrop a cropped image it's trying to crop it from the original and not from the cropped file.
When I try adding an :original style to see if that works the original is cropped but then all the other images are basically blank.
How do I get a paperclip processor to apply the transformation to the original image and save it as well as the styles?
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.
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