LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Software (https://www.linuxquestions.org/questions/linux-software-2/)
-   -   Command Line Image Editing (https://www.linuxquestions.org/questions/linux-software-2/command-line-image-editing-366109/)

fractal_chaos 09-22-2005 09:23 PM

Command Line Image Editing
 
Hello all:

I have a script that generates an image which I distribute to co-workers each day. I would like to place the company logo in the corner of this image, but can only do so AFTER the image has been created.

I've been re-searching the plethora of image processing tools that Linux can use, but haven't found something that helps me do what I want to do. Namely, overlay two images via the command line with some geometry control (i.e. where the logo gets placed).

Maybe I'm missing something? Anyone have a hint/suggestion about this?

Thanks!

-matt

foo_bar_foo 09-22-2005 09:56 PM

i don't really know for sure but you might be able to do that with python imaging library
http://www.pythonware.com/products/pil/

homey 09-23-2005 01:21 AM

ImageMagick has several goodies like mogrify, composite and convert. I used convert in these examples.

The first two examples actually make another image where the text will reside. The two images are joined by the -append command.
It's important to enclose the text in single quotes if it has a word string like 'Not Now'

You will need to play with size and position as I was using a small image.
Code:

convert xc:white -resize 100x20! blank.png |\
convert -append tux.png blank.png tmp.png |\
convert tmp.png -gravity south -font helvetica -pointsize 15 \
-fill blue -draw "text -20+0 Cockatoo" tux1.png

convert xc:white -resize 100x20! blank.png |\
convert -append tux.png blank.png tmp.png |\
convert tmp.png -gravity south -font helvetica -pointsize 15 \
-fill red -draw "text -20+0 'Not Now'" tux2.png

convert tux.png -gravity center -font helvetica -fill blue \
-draw "text 0+5 Cockatoo" tux3.png

convert tux.png -font Helvetica -pointsize 15 -fill red \
-gravity center -draw "text 0+0 'Not Now'" tux4.png


fractal_chaos 10-03-2005 02:32 PM

Thanks!

ImageMagick worked mint. I used the following ...

$ convert -flatten old.gif logo.gif new.gif

to place "logo.gif" in the upper-left hand corner of the original image "old.gif" and form a new image "new.gif"

-matt

homey 10-03-2005 04:18 PM

Glad it worked for you! I hadn't even thought that your logo was a gif and not just text.
Now if I can just figure out how to move that gif around like I do with -gravity for text.

fractal_chaos 10-03-2005 04:31 PM

right. i hadn't figured the moving part out either, but i guess the default is upper-left, and that worked nicely, so i left it alone...

homey 10-03-2005 05:27 PM

I am able to change it by using composite to positions north, south, east, west and center. Also, you can combine most of them but center which acts alone.
For example: northeast or southeast.

There doesn't seem to be any fine tuning of position like I did with text and convert.
For example: -gravity northwest -draw "text 0-10 'Not Now'"

So here's what I came up with using composite
Code:

composite -gravity southeast logo.gif earth.png earth1.png

fractal_chaos 10-03-2005 05:30 PM

Yes, that works mint! Thanks...

homey 10-03-2005 05:33 PM

You're welcome!


All times are GMT -5. The time now is 07:05 PM.