I'd like to insert arguement as text onto the image file that user uploads.
With the code below, It doesn't work. It just saves image without any effect.
I'm using the gem called 'papaerclip' for uploading.
comment.rb
#paperclip
has_attached_file :comment_icon,
:styles => {
:thumb=> "100x100>",
:small => "400x400>" },
:convert_options => {
:all => " -stroke '#000C' -strokewidth 2 -annotate 0 'Faerie Dragon' -stroke none -fill white -annotate 0 'Faerie Dragon'" }
How can I insert text to the bottom of images like this example?
How comment.rb should be written?
ImageMagick code
convert dragon.gif -gravity south \
-stroke '#000C' -strokewidth 2 -annotate 0 'Faerie Dragon' \
-stroke none -fill white -annotate 0 'Faerie Dragon' \
anno_outline.jpg
It doesn't like the single quotes you have in your convert_options. Try using:
' -gravity south -stroke "#000C" -strokewidth 2 -annotate 0 "Faerie Dragon" -stroke none -fill white -annotate 0 "Faerie Dragon"'
instead. I am using Paperclip 3.2.0 and was able to get it to apply the text by changing the quotes.
Here is my image attribute:
has_attached_file :avatar,
:styles => {:large => "300x300", :medium => "140x140>", :thumb => "100x100>", :tiny => "50x50" },
:storage => :s3,
:s3_credentials => "#{Rails.root}/config/amazons3.yml",
:path => "avatars/:id/:style_:filename",
:convert_options => {
:all => ' -gravity south -stroke "#000C" -strokewidth 2 -annotate 0 "Faerie Dragon" -stroke none -fill white -annotate 0 "Faerie Dragon"' }
Related
Welcome, help crop the image,
has_attached_file: image, styles: {show: '540x505 #'}
trims as needed, but is centered on the (up), I need to image is not centralized, and trimmed the top
Original image:
Need:
You want to set the -gravity option to North when defining paperclip's style. Something like...
has_attached_file: image,
styles: {show: '540x505'},
convert_options: {show: ' -gravity North '}
See documents & example usage here.
Answer:
has_attached_file :image, styles: { show: '' },
convert_options: {show: '-gravity north -thumbnail 540x505^ -extent 540x505' }
My codes are written like this.
It insert "text_here" to the uploaded image file.
This text is in white color with black shadow in behind.
In spite of the fact I'm stating -pointsize 15 twice, it larges only the
has_attached_file :user_avatar,
:styles => {
:thumb=> "100x100>",
:small => "400x400>" },
:convert_options => {
:small => ' -gravity south -stroke "#000C" -strokewidth 2 -annotate 0 " text_here! " -pointsize 15 -stroke none -fill white -annotate 0 " text_here! " -pointsize 15' }
a/ I do not completly know what you want to do but put the -pointsize before the -annotate.
b/ If one is a black shadow why do you need two differnt point sizes.
c/ Why are you using stroke ?
Try this:
:small => ' -gravity south -pointsize 15 -fill black -annotate +0+0 " text_here! " -fill white -annotate +2+2 " text_here! "' }
So I have a Rails 3 app using Paperclip to crop images.
I have this code in my model for Photo:
has_attached_file :thumbnail, PAPERCLIP_OPTIONS.merge(
:styles => {:cropped => '300x250#'})
The resulting image that's generated creates a 300x250 image, however the crop seems to always start a good 50px or so below the top of the image (not a good thing for social networking when it cuts off the top of peoples heads).
I did some research and I'm thinking I need to supply a :convert_options key that coincides with the :cropped style. However, I don't know exactly what options to set (-gravity, -region, etc.)
Anybody have any thoughts. I know there are Imagemagick pros; I'm not one, lol.
Thanks!
Update:
I found this link..
http://forrst.com/posts/Customized_Cropping_with_Paperclip-7g6
Is this still valid or does somebody have a better easier way?
Here's my favorite way to do it:
:styles => { :large => "", :medium => "", :thumb => ""},
:convert_options => {
:large => "-gravity north -thumbnail 300x300^ -extent 300x300" ,
:medium => "-gravity north -thumbnail 200x200^ -extent 200x200",
:thumb => "-gravity north -thumbnail 100x100^ -extent 100x100"
}
Note that instead of # you use ^ + extent.
Gravity parameters are like on a map: north, northeast, east ...
I can do this command to resize an image to fit a specific size on the command line with Imagemagick. How do I tell paperclip can do the same when I upload an image:
convert Bisiye2.jpg -thumbnail '150x150^' -gravity center -extent 150x150 Bisiye2_tofit.jpg
has_attached_file :image, :styles => { :thumb => "150x150>" },
:convert_options => {:thumb => "-gravity center -extent 150x150"}
I upload a photo, it is a rectangle. How Can I get it resized and filled to a square ?
I mean when the photo is horizontal positioned it should have above and under it, two white fields (for keeping the shape of a square) and when it is vertically, it should have two white fields on the sides of the photo.
When I used PHP, a have used this http://www.verot.net/php_class_upload_samples.htm
Have a look at the
100x150, keeping ratio, filling top and bottom
example
I'm using Paperclip with RoR. How is the best way to do that ?
Here's what I used on a rails 3 app w/ paperclip. I used the following ImageMagick options to make it centered: background, compose, gravity and extent. I'm using the mini_magick processor.
has_attached_file :image,
:styles => { :large => ["855x570>", :jpg], :medium => ["432x288>", :jpg], :small => ["276x184>", :jpg], :tiny => ["195x130>", :jpg] },
:processor => "mini_magick",
:convert_options => {
:medium => "-background white -compose Copy -gravity center -extent 432x288",
:small => "-background white -compose Copy -gravity center -extent 276x184",
:tiny => "-background white -compose Copy -gravity center -extent 195x130"
}