Advertisement
metalx1000

Convert a Color to Transparent with ImageMagick

Mar 30th, 2025
598
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Bash 0.33 KB | None | 0 0
  1. #Remove the background color from an image
  2. #get the color of the first pixel
  3. magick img.bmp -format "%[hex:p{0,0}]" info:
  4.  
  5. #convert the image to a png
  6. #and use the color of the first pixel as the transparent color
  7. for img in *.bmp
  8. do
  9.   echo "${img%.bmp}"
  10.   magick "$img" -transparent "#%[hex:p{0,0}]" "${img%.bmp}.png"
  11. done
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement