I'm learning to use ImageMagick, but I'm having trouble when I try to generate an image like the example below:
And for that, I'm using the following code:
convert original.jpg -size 460x caption:'This is a multiline caption, This is a multiline caption, This is a multiline caption.' result.jpg
This command generated two separate images, one with just the title. Can you help me?
PS: I'm using RubyOnRails with ImageMagick, but you can suggest examples with MiniMagick or Rmagick. Thanks.
This works in php and I can not see why it will not work o RubyOnRails:
convert original.jpg -size 460x -background transparent -fill black -pointsize 40 caption:'This is a multiline caption, This is a multiline caption, This is a multiline caption.' -gravity center -composite result.jpg
Related
I would like to take this logo and place it on a black background.
I am using the below script
convert -size 4000x4000 canvas:#000000 -background \#000000 background.jpg
composite rev.jpg -gravity center background.jpg output.jpg
open output.jpg
Which generates. As you can see the colours have changed and I cannot work out why?
Just set the colorspace.
composite 03wp2.jpg -colorspace srgb -gravity center background.jpg output.jpg
Possibly a colour profile or are you using CMYK for the rev.jpg?
Try this which will shorten your code:
convert rev.jpg -background black -gravity center -extent 4000x4000 output.jpg
I trying to add a caption to existing image, but it produce two images, one with actuall caption and another just copy of source image...
Doing it by trying these examples http://www.imagemagick.org/Usage/text/#caption
like
convert Book.png -background lightblue -fill blue \
-size 320x caption:'This is a very long caption line.' \
caption.png
result is two images caption-0.png and caption-1.png
What am I doing wrong here?
Try this:
convert Book.png ( -size 320x -background lightblue -fill blue caption:"This is a very long caption line." ) -gravity center -composite caption.png
I am not sure you can leave out the height of the caption as the font size is calculated to fit the caption bounding box.
I'm trying to generate an image using Imagemagick to match a preview in the browser, but the text comes out blurry. Does anybody have any suggestions? Attached is an image with the Imagemagick one on top, and browser one on bottom, along with the IM code.
convert -density 288 -resize 25% -background white -fill black -strokewidth 0 -stroke white -font Rubik-Regular.ttf -pointsize 10 -gravity center label:'This is a TEST!' label_arial.gif
You might find it easier to start with caption which automatically sizes the text the best way to fill a given area. So, as your lettering is around 140x36 pixels, you would do:
convert -size 140x36 -gravity center caption:'This is a TEST!' label.gif
I want to convert different image formats (bmp,jpg,gif,png,tiff-incluging multipaged) into a PDF format with A4 page size and with images fit to page (resized if necessary). Image should be positioned at the center of the page and I'd like to define an offset.
I tried the code below but there is no offset at the top and the image quality is really poor.
convert png.png -gravity North -resize 500x500 -quality 100 -page a4x5x5 myout.pdf
Is there any way to do that?
Thanks in advance for any help,
Mariusz
If you want to keep the original resolution (lossless) you can try the following command:
convert png.png -background white -page a4 myoutput.pdf
Based on a comment posted before: https://stackoverflow.com/a/24573341/6747994
#m4tx This command only makes sense if the picture has a resolution above 500x800px, it does not zoom in, to avoid pixelated thumbnails.
You can convert to pdf using ImageMagick
convert png.png myout.pdf
but use pdfjam instead of ImageMagick to adjust the page size
pdfjam --paper a4paper --outfile myoutA4.pdf myout.pdf
pdfjam offers other options, which may fit your needs.
Found this somewhere on stackoverflow:
convert *.jpg -resize 1240x1753 \
-extent 1240x1753 -gravity center \
-units PixelsPerInch -density 150x150 multipage.pdf
Thanks to the ImageMagick support forum I was able to find a solution:
convert image.tif -resize 575x823^> -gravity center -background white -extent 595x842 image.pdf
If you get an error try:
convert image.tif -resize 595x842^\> -gravity center -background white -extent 595x842 image.pdf
You need to specify the density:
convert -density 80 -page a4 input_A.jpg input_B.jpg output.pdf
Otherwise, there can be an issue when printing with "actual size" instead of "fit". I have used a public printer where I could not choose "fit" and had to choose "actual size", in which case the printed page was only a part of the page which I wanted to print.
I need to be able to apply watermark on an image, using either text or another image.
Getting it to work with an image was quite straight forward, using the following command:
gm composite -dissolve 15 -tile logo.png image.jpg wmark_tiled.jpg
Now, I also want to be able to use text for watermarking (in other cases). The only thing that I found close to it, is a command from ImageMagick tutorial which is the following :
convert -size 140x80 xc:none -fill grey -gravity NorthWest -draw "text 10,10 'copyrigh text'" -gravity SouthEast -draw "text 5,15 'copyright text'" miff:- | gm composite -tile - image.jpg copyrightImage.jpg
Although its not working in GM, and I would rather avoid using pipe as it causes some headaches managing it from Java.
What I thought I could do, is generate an image from a given text, and then use that image as logo.png is used on my first command. Although I cannot find how to generate an image out of text, all I find is putting text on top of an image.
Ideally I will generate a transparent image with the text, and from what I see modifying font/color etc should be quite flexible.
Any suggestions on how to achieve this, or any better solutions are welcome.
(I added imagemagick tag as the interfaces are often same/similar)
I'm not sure I fully understand your query, so apologies if I've misunderstood, but are you trying to create a transparent image, with some text in the corner? If so, would this not work?
convert -background transparent -fill grey -font Calibri -size 140x80 -pointsize 14 -gravity southeast label:'copyright text' output.png
Obviously adjusting the font, pointsize, output image name etc. That would create the following:
http://oi42.tinypic.com/14j1bvp.jpg
P.S. that was written for ImageMagick. I don't know how GM differs or whether it would still work.
To be able to get the watermark text into the same image I had to use the -annotate parameter.
So Moogle's code snippet would look like this in my case:
convert original_image.jpg -background transparent -fill grey -font Calibri -size 140x80 -pointsize 14 -gravity southeast -annotate +0+0 'copyright text' output.jpg