Difference between revisions of "Images"
(→Colour Picker app: add transparent bg conversion) |
(imagemagick tricks) |
||
Line 35: | Line 35: | ||
Highly recommended! http://instant-eyedropper.com/ | Highly recommended! http://instant-eyedropper.com/ | ||
+ | |||
+ | |||
+ | == Contact Sheet with ImageMagick == | ||
+ | |||
+ | montage -verbose -label '%f' -pointsize 14 \ | ||
+ | -background 'white' -fill 'black' \ | ||
+ | -define jpeg:size=300x300 -geometry 300x300+2+2 \ | ||
+ | -auto-orient *.png ../output.png | ||
+ | |||
+ | <code>-label '%f'</code> specifies to use the filename as a label for each image | ||
+ | <code>-tile 10x</code> makes it output 10 badges per row | ||
+ | |||
+ | == Count the unique colours in an image == | ||
+ | |||
+ | This can be useful if an image won't reduce in size by much (e.g to an 8 bit colour map). | ||
+ | |||
+ | $ file MyImage.png | ||
+ | MyImage.png: PNG image data, 400 x 400, 8-bit/color RGB, non-interlaced | ||
+ | |||
+ | ImageMagick has a command to count how many colours there are in an image: | ||
+ | |||
+ | $ identify -format %k MyImage.png | ||
+ | 2310 |
Latest revision as of 13:56, 21 August 2019
Contents
Changing colours with ImageMagick
Converting true black rgb(0,0,0) in an image to rgb(0,0,10) to force composite black:
name=MyLogoImage.png convert "$name" -depth 32 -type TrueColorMatte -alpha set -channel RGBA -fill 'rgb(0,0,10)' -opaque 'rgb(0,0,0)' "PNG32:new-$name"
This will create a file called new-MyLogoImage.png that should have the same properties shown by the file
command. The difference will be that the black is no longer true black and is suitable for use with LG Plates.
MyLogoImage.png: PNG image data, 522 x 97, 8-bit/color RGBA, non-interlaced
The RGBA provides the alpha channel (partial transparency) which is sometimes used for smoother edges rather than using shades of the main colour.
A similar command could be used to -fill 'rgb(250,250,250)' -opaque 'rgb(255,255,255)'
replace pure white with off-white for use with a Pro printer. There may be some fuzzing required (-fuzz 5% for example) where badges use a shade of white such as rgb(253,253,253) since this wouldn't be picked up as exactly rgb(255,255,255) but would still be translated by the printer into transparency. The actual fuzz value may need some experimentation.
Extend image and fill new canvas
Extend the file to 590x4015 from whatever the current size is. Centre the original image on the new canvas and fill the extra canvas with solid blue (#0000ff). The new image has the colour depth adjusted to the minimum so it's quite a good way of shrinking the files.
-rw-rw-r-- 1 plates plates 11216 Nov 14 12:14 Union Flag Eng 2.png Union Flag Eng 2.png: PNG image data, 590 x 2480, 8-bit colormap, non-interlaced
convert "$name" -background blue -gravity Center -depth 32 -extent '590x4015' "new-$name"
-rw-r--r-- 1 plates plates 4640 Dec 14 15:52 new-Union Flag Eng 2.png new-Union Flag Eng 2.png: PNG image data, 590 x 4015, 2-bit colormap, non-interlaced
Convert transparent background to white
Replace white with any other colour as required!
convert transparentbgimage.png -transparent-color white -background white -layers flatten -depth 32 outputimage.png
Colour Picker app
Highly recommended! http://instant-eyedropper.com/
Contact Sheet with ImageMagick
montage -verbose -label '%f' -pointsize 14 \ -background 'white' -fill 'black' \ -define jpeg:size=300x300 -geometry 300x300+2+2 \ -auto-orient *.png ../output.png
-label '%f'
specifies to use the filename as a label for each image
-tile 10x
makes it output 10 badges per row
Count the unique colours in an image
This can be useful if an image won't reduce in size by much (e.g to an 8 bit colour map).
$ file MyImage.png MyImage.png: PNG image data, 400 x 400, 8-bit/color RGB, non-interlaced
ImageMagick has a command to count how many colours there are in an image:
$ identify -format %k MyImage.png 2310