Using transparent on the command line

Questions and postings pertaining to the usage of ImageMagick regardless of the interface. This includes the command-line utilities, as well as the C and C++ APIs. Usage questions are like "How do I use ImageMagick to create drop shadows?".
Post Reply
sftriman

Using transparent on the command line

Post by sftriman »

I am trying to create square images by making a border on images and then cropping.
Here is the command I've been trying to get to work:

convert original.jpg -bordercolor "#e6a7c8" -transparent "#e6a7c8" -thumbnail 57x57 -gravity center -format jpg -border 60x60 -crop 57x57+0+0 new.jpg

It does everything I want it to do except to change the color #e6a7c8 to clear.
I tried -opaque in conjunction with -fill as well. No go. I also tried doing the
convert above first without the -transparent part, and then a 2nd convert as:

convert -transparent "#e6a7c8" new.jpg new.jpg

but that didn't work either.

I looked into -alpha, but my version of convert doesn't have that. Nor does it
have the -transparent-color option. I also tried setting -background colors.
Setting the color itself to "transparent" makes the color black.

I have this version:

Version: ImageMagick 6.0.7 07/25/08 Q16 http://www.imagemagick.org
Copyright: Copyright (C) 1999-2004 ImageMagick Studio LLC

Any suggestions on how to get a transparent border color when I create
square images?

Thanks!
David
el_supremo
Posts: 1015
Joined: 2005-03-21T21:16:57-07:00

Re: Using transparent on the command line

Post by el_supremo »

I'm not clear on what you're trying to achieve but the JPG format does not support transparency.
Try using PNG format for the output.

Pete
Sorry, my ISP shutdown all personal webspace so my MagickWand Examples in C is offline.
See my message in this topic for a link to a zip of all the files.
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: Using transparent on the command line

Post by fmw42 »

try this

convert logo: -thumbnail 57x57 -gravity center -background none -extent 57x57 logo_thumb.png

Note: as el_supremo said, jpg does not support transparency on output. So your output must be either png or gif.
Post Reply