After trying every combination of commands that I could possibly think of I still can't get this to work.
I have a large image that can vary in size: Logo.png
I have a small image of a 'known' size: Wallpaper.png
I want Logo to appear in the Bottom Left of Wallpaper.
This has to be done using the 'gm convert' command using -flatten. Using 'gm composite' would require me to run two commands which isn't acceptable as it would add too much time to our processing per image.
Here is the command so far (there will be more added to this command but here is the core of it):
wallpaper.png -page +0+0 -gravity SouthWest logo.png -compose over -flatten result.jpg
This puts the logo in the top left. Gravity appears to be ignored. Using +100% for -page does not work either.
I don't see the need for your use of -flatten and +page
The following ImageMagick command should work:
convert \
-composite \
-geometry +10+20 \
-gravity southwest \
background.png \
logo.png \
result.png
For GraphicsMagick this needs to change to:
gm \
composite \
-geometry +10+20 \
-gravity southwest \
logo.png \
background.png \
result.png
I added +10+20 to demonstrate how you can offset the overlaid logo a little bit from the extreme lower left corner.
Related
I've a round image and I need to put some circle text on it.
The text is from the frontend where the preview is build with CircleType.js (http://circletype.labwire.ca/) a jQuery Plugin.
$("span#text").circleType({
radius: 102,
dir: -1
});
I checked http://www.imagemagick.org/Usage/fonts/ without a solution
currently I get this result
with the following code:
convert \
-background none \
-font Candice \
-pointsize 32 \
-fill navy label:\"A short TEST text\" \
-rotate 180 \
-distort Arc '270 180' \
outfile.png
but it isn't ever the same radius / distance to the border, base on the text length like in the first image.
Can somebody help me, please
Not sure exactly what you want, but you can hopefully see how to get there from this.
Like this maybe:
convert \
-background yellow \
-pointsize 64 \
-fill navy label:"A longer test text" \
-rotate 180 \
-distort arc '270 180' \
-trim +repage -resize 400x400 -gravity south -extent 400x400! outfile.png
How to modify this code so mogrify will generate thumbnails only for the first frame of animated gifs?:
mogrify -resize 80x80 -background white -gravity center -extent 80x80 -format jpg -quality 75 -path thumbnails *.gif
The select frame notation would be [N] immediately after the filename; where N is the frame number you wish to select. See Selecting Frames section under the input filename examples.
mogrify -resize 80x80 \
-background white \
-gravity center \
-extent 80x80 \
-format jpg \
-quality 75 \
-path thumbnails \
*.gif[0]
I was following this example http://cubiq.org/create-fixed-size-thumbnails-with-imagemagick, and it's exactly what I want to do with the image, with the exception of having the background leftovers (i.e. the white borders). Is there a way to do this, and possibly crop the white background out? Is there another way to do this? The re-size needs to be proportional, so I don't just want to set a width re-size limit or height limit, but proportionally re-size the image.
The example you link to uses this command:
mogrify \
-resize 80x80 \
-background white \
-gravity center \
-extent 80x80 \
-format jpg \
-quality 75 \
-path thumbs \
*.jpg
First, mogrify is a bit dangerous. It manipulates your originals inline, and it overwrites the originals. If something goes wrong you have lost your originals, and are stuck with the wrong-gone results. In your case the -path thumbs however alleviates this danger, because makes sure the results will be written to sub directory thumbs
Another ImageMagick command, convert, can keep your originals and do the same manipulation as mogrify:
convert \
input.jpg \
-resize 80x80 \
-background white \
-gravity center \
-extent 80x80 \
-quality 75 \
thumbs/output.jpg
If want the same result, but just not the white canvas extensions (originally added to make the result a square 80x80 image), just leave away the -extent 80x80 parameter (the -background white and gravity center are superfluous too):
convert \
input.jpg \
-resize 80x80 \
-quality 75 \
thumbs/output.jpg
or
mogrify \
-resize 80x80 \
-format jpg \
-quality 75 \
-path thumbs \
*.jpg
I know this is an old thread, but by using the -write flag with the -set flag, one can write to files in the same directory without overwriting the original files:
mogrify -resize 80x80 \
-set filename:name "%t_small.%e" \
-write "%[filename:name]" \
*.jpg
As noted at http://imagemagick.org/script/escape.php, %t is the filename without extension and %e is the extension. So the output of image.jpg would be a thumbnail image_small.jpg.
This is the command I use each time I want to batch resized everything to 1920x and keep aspect ratio.
mogrify -path . -resize 1920x1920 -format "_resized.jpg" -quality 70 *.jpg
I have a case where I need to combine two transparent layers on top of JPEG files.
Here a sample setup:
wget -O bg.jpg http://www.grahamowengallery.com/photography/Flowers/roadside-flowers.jpg
wget -O layer.png http://www2.picturepush.com/photo/a/6271450/640/TRANSPARENT-EMBELLISHMENTS/pink-flower-transparent-png.png
wget -O logo.png http://upload.wikimedia.org/wikipedia/commons/0/0d/Imagemagick-logo.png
I can get desired result with commands:
composite bg.jpg \( -compose Overlay layer.png \) bg2.jpg
composite bg2.jpg \( -compose Overlay logo.png \) result.jpg
This is good, but I want to avoid writing bg2.png to drive.
I tried:
composite bg.jpg \( -compose Overlay layer.png \) \( -compose Overlay logo.png \) result2.jpg
but this results on layer.png on black background. How can I fix this?
I couldn't make composite working, but convert works:
convert.exe bg.jpg layer.png -compose Overlay -composite logo.png -compose Overlay -composite result2.jpg
Further reading: http://www.imagemagick.org/Usage/compose/
I can not test this at the moment but you may be able to use layers merge and you should be able to use the URLs in your code.
$cmd = "http://www.grahamowengallery.com/photography/Flowers/roadside-flowers.jpg ".
" http://www2.picturepush.com/photo/a/6271450/640/TRANSPARENT-EMBELLISHMENTS/pink-flower-transparent-png.png ".
" http://upload.wikimedia.org/wikipedia/commons/0/0d/Imagemagick-logo.png -layers merge ";
exec(" convert $cmd result.jpg ");
You are not using any positioning for your layers - are you going to introduce that later? If so you can add -page +0+0 in front of each image to locate them where you want. +0+0 would be changed to the location.
I have a simple text file that reads something like "It is 28 degrees today" I am trying to use imagemagick to center it to the middle of the image. The command i am using is this right now
`convert -background lightblue -fill blue -size 165x70 filename.txt image.png`
I tried using gravity but it always put the text outside of the image for some reason. I am not using it correctly from what I can see. I would like it to be centered. Any suggestions?
convert \
-size 165x70 \
xc:lightblue \
-font Bookman-DemiItalic \
-pointsize 12 \
-fill blue \
-gravity center \
-draw "text 0,0 'It is 28 degrees today'" \
image.png
If you want to pull the input from an existing file, just feed that to the draw command:
convert \
-size 165x70 \
xc:lightblue \
-font Bookman-DemiItalic \
-pointsize 12 \
-fill blue \
-gravity center \
-draw "text 0,0 '$(cat file.txt)'" \
image.png
Look At this
convert temp.jpg -gravity Center -pointsize 30 -annotate 0 'Love you
mom' temp1.jpg
'i love u mom' text word
gravity positioning center place of the text