Thumbnails using images with transparency
Thumbnails using images with transparency
Hi,
I've been searching for a way to do the following and struggling.
I have been using convert and -thumbnail and a size for a while and all has been well. However I now need to extend this a little to cope with images that have transparency, I've set the Alpha layer to white or black but then found that depending on the content of the image this looks awful. I don't know ahead of time which colour to use.
Is there a way I can use convert to replace the transparent Alpha layer with the built in checkerboard, which is universally seen as transparent, and resize down with the -thumbnail to a jpg.
Just to make this more fun I need this in one execution and able to run on PC or Mac from a command line.
Many thanks
I've been searching for a way to do the following and struggling.
I have been using convert and -thumbnail and a size for a while and all has been well. However I now need to extend this a little to cope with images that have transparency, I've set the Alpha layer to white or black but then found that depending on the content of the image this looks awful. I don't know ahead of time which colour to use.
Is there a way I can use convert to replace the transparent Alpha layer with the built in checkerboard, which is universally seen as transparent, and resize down with the -thumbnail to a jpg.
Just to make this more fun I need this in one execution and able to run on PC or Mac from a command line.
Many thanks
-
- Posts: 12159
- Joined: 2010-01-23T23:01:33-07:00
- Authentication code: 1151
- Location: England, UK
Re: Thumbnails using images with transparency
Sure. For example:
Code: Select all
convert -size 300x100 -background none label:snibgo pattern:checkerboard +swap -composite c.png
snibgo's IM pages: im.snibgo.com
Re: Thumbnails using images with transparency
Hi,
Thanks for your reply, it didn't work though, here are my results.
- replaced transparent backgraound with the checkerboard and the text "snibgo"
I also tried outputting to a file to see if that helped
- it created 2 files
1) out-0.jpg, with the background and the text "snibgo"
2) out-1.jpg, copy of in.eps but with white background
Thanks
Thanks for your reply, it didn't work though, here are my results.
Code: Select all
convert -size 300x100 -background none label:snibgo pattern:checkerboard +swap -composite in.eps
I also tried outputting to a file to see if that helped
Code: Select all
convert -size 300x100 -background none label:snibgo pattern:checkerboard +swap -composite in.eps out.jpg
1) out-0.jpg, with the background and the text "snibgo"
2) out-1.jpg, copy of in.eps but with white background
Thanks
-
- Posts: 12159
- Joined: 2010-01-23T23:01:33-07:00
- Authentication code: 1151
- Location: England, UK
Re: Thumbnails using images with transparency
"-size 300x100 -background none label:snibgo" is just an example image. Replace it with your own image, so you might have:
This should replace transparency with checkerboard, which I think is what you want.
Code: Select all
convert in.png pattern:checkerboard +swap -composite out.png
snibgo's IM pages: im.snibgo.com
Re: Thumbnails using images with transparency
Sorry, still no go, but what you describe what I am trying to achive is correct.
The eps file is a simple 2.5 cm square box with text written in the forground in black in 1 layer if opened in photoshop but you can pick the text up and move it around with the move tool. I don't think I can attach it to the group but here are my results again.
Black image
Black image
Checkerboard in top left of image on top of everything
If it helps I am using the following and testing on PC
Imagemagick version 6.7.9-0 2012-08-14 Q16
Ghostscript version 9.06 (2012-08-08)
The eps file is a simple 2.5 cm square box with text written in the forground in black in 1 layer if opened in photoshop but you can pick the text up and move it around with the move tool. I don't think I can attach it to the group but here are my results again.
Code: Select all
convert in.eps pattern:checkerboard +swap -composite out.png
Code: Select all
convert in.eps pattern:checkerboard +swap -composite out.jpg
Code: Select all
convert in.eps pattern:checkerboard -composite out.png
If it helps I am using the following and testing on PC
Imagemagick version 6.7.9-0 2012-08-14 Q16
Ghostscript version 9.06 (2012-08-08)
-
- Posts: 12159
- Joined: 2010-01-23T23:01:33-07:00
- Authentication code: 1151
- Location: England, UK
Re: Thumbnails using images with transparency
v6.7.9 is 3 (?) years old. I suggest you upgrade.
I know nothing about eps and don't have a viewer for them.
Does my command work for you?
You should get "snibgo" in black letters over a checker background.
Next test: what does ...
... give? Black text on a transparent background, or what?
I know nothing about eps and don't have a viewer for them.
Does my command work for you?
Code: Select all
convert -size 300x100 -background none label:snibgo pattern:checkerboard +swap -composite c.png
Next test: what does ...
Code: Select all
convert in.eps out.png
snibgo's IM pages: im.snibgo.com
Re: Thumbnails using images with transparency
Code: Select all
convert -size 300x100 -background none label:snibgo pattern:checkerboard +swap -composite c.png
Code: Select all
convert in.eps out.png
-
- Posts: 12159
- Joined: 2010-01-23T23:01:33-07:00
- Authentication code: 1151
- Location: England, UK
Re: Thumbnails using images with transparency
So they don't have transparency. I'm confused. What are you trying to do?rpalmer wrote:This gives me a white backgrounded with the black text in the foreground
snibgo's IM pages: im.snibgo.com
Re: Thumbnails using images with transparency
The plot thickens.
I opened the EPS in Photoshop, which shows it having transparency, and "saved as" a PNG. I then ran your suggested
This has given me a checkerboard background but only showing me a small portion of the image so I guess a size needs to be added or a tile (I've seen somewhere).
Could it be the way the EPS is read in the first place?
Excuse the questions I am very much a novice with Imagemagick!
I opened the EPS in Photoshop, which shows it having transparency, and "saved as" a PNG. I then ran your suggested
Code: Select all
convert in.png pattern:checkerboard +swap -composite out.png
Could it be the way the EPS is read in the first place?
Excuse the questions I am very much a novice with Imagemagick!
-
- Posts: 12159
- Joined: 2010-01-23T23:01:33-07:00
- Authentication code: 1151
- Location: England, UK
Re: Thumbnails using images with transparency
An EPS (Encapsulated PostScript) file may contain only vectors, so when you rasterise it (convert to pixels) you may need to say how many pixels you want. For IM, you do this with "-density 72 -units pixelsperinch" or similar, before the input image.
snibgo's IM pages: im.snibgo.com
- fmw42
- Posts: 25562
- Joined: 2007-07-02T17:14:51-07:00
- Authentication code: 1152
- Location: Sunnyvale, California, USA
Re: Thumbnails using images with transparency
This works perfectly fine for me on IM 6.8.8.4 Q16 Mac OSX (Ghostscript 9.06) using IM's display to view it.
What is your IM version, platform and ghostscript version?
convert -version
gs --version
Probably you need to upgrade GS and perhaps IM.
Code: Select all
convert -size 300x100 -background none label:snibgo pattern:checkerboard +swap -composite in.eps
convert -version
gs --version
Probably you need to upgrade GS and perhaps IM.
Re: Thumbnails using images with transparency
Hi thanks for your help so far guys.
I've upgraded to the following versions just to make sure
convert -version
Version: ImageMagick 6.8.8-3 Q8 x64 2014-01-19
gswin64 -version
GPL Ghostscript 9.10 (2013-08-30)
Still gives me a black image with small visible check line at the bottom
When I open the EPS in Photoshop it does ask me for
Width (and in what)
Height (and in what)
Resolution (and in what)
Mode (Greyscale, RGB etc)
Anti-aliased (true/false)
Constrain Proportions (true/false)
Export the imported EPS from Photoshop to a PNG with transparency, doing nothing other than opening and saving.
Works but only 1 checkerboard behind it while examples I've seen looked more like a chess board but guess I need another attribute to make that happen
So, changing the version has made no difference but hopefully I've given a little more insight.
Thanks for all your help, this has been driving me crazy!
I've upgraded to the following versions just to make sure
convert -version
Version: ImageMagick 6.8.8-3 Q8 x64 2014-01-19
gswin64 -version
GPL Ghostscript 9.10 (2013-08-30)
Code: Select all
convert -thumbnail 80x80 -density 72 -units pixelsperinch in.eps pattern:checkerboard +swap -composite out.jpg
When I open the EPS in Photoshop it does ask me for
Width (and in what)
Height (and in what)
Resolution (and in what)
Mode (Greyscale, RGB etc)
Anti-aliased (true/false)
Constrain Proportions (true/false)
Export the imported EPS from Photoshop to a PNG with transparency, doing nothing other than opening and saving.
Code: Select all
convert -thumbnail 80x80 -density 72 -units pixelsperinch in.png pattern:checkerboard +swap -composite out.jpg
So, changing the version has made no difference but hopefully I've given a little more insight.
Thanks for all your help, this has been driving me crazy!
-
- Posts: 12159
- Joined: 2010-01-23T23:01:33-07:00
- Authentication code: 1151
- Location: England, UK
Re: Thumbnails using images with transparency
If you post your eps file somewhere like dropbox.com and paste the URL here, we can experiment.
snibgo's IM pages: im.snibgo.com
-
- Posts: 12159
- Joined: 2010-01-23T23:01:33-07:00
- Authentication code: 1151
- Location: England, UK
Re: Thumbnails using images with transparency
ImageMagick can't see any transparency in in.eps.
From comments on these forums, it seems that Photoshop has two different types of transparency, and IM can see only one of them.
From comments on these forums, it seems that Photoshop has two different types of transparency, and IM can see only one of them.
snibgo's IM pages: im.snibgo.com