GraphiccMagick, how to remove alpha channel - graphics

Tell me please, how to convert PNG to JNG without alpha channel in GraphicsMagick?

JPG? JPG has no alpha channel, after you convert PNG to JPG, alpha channel will be remove automatically.

If you are trying to remove alpha from png you can use convert (imagemagick):
convert in.png -background black -alpha remove -alpha off -resize 1024x1024 out.png

Related

Convert svg animation to apng sequence

Is there any way to do this?
I tried magick -background none in.svg out.png with ImageMagick 7.1.0-61, it removed the transparency and only kept the first frame of animation.

GraphicsMagick / ImageMagick replace all non-transparent pixels (like Photoshop's Color Overlay)

I'm trying to replace all non-transparent pixels to a given color using GraphicsMagick for Node.
Using a composite image is not an option, I simply need to change every non-transparent pixel to a given color.
Original image:
Goal:
Transparent pixels should stay transparent. I'm trying to achieve Photoshop's Color Overlay effect:
This is a bit simpler. In ImageMagick do the following:
convert 84xHk.png -fill "#E91FCB" +opaque none result.png
I'm not familiar with Node's GraphicsMagick library, but there are a few methods to achieve this. Here's a few I can think of...
Extract alpha, and replace colors
convert 84xHk.png -alpha extract \
-negate -fill '#E91FCB' -fuzz 50% \
-opaque black output.png
Create solid color image, and copy alpha channel
convert 84xHk.png \
\( +clone -alpha off \
-fill '#E91FCB' \
-draw 'color 0,0 reset' \
\) +swap -compose CopyOpacity -composite output.png
Use FX expressions
convert 84xHk.png -fx 'p.a==1?#E91FCBFF:#E91FCB00' output.png

linux convert thumbnail but move position

I have used linux convert command to successfully create thumbnails as follows:
$disposition='200x200';
$str="convert -size $disposition \"$fullPath\" -resize $disposition +profile '*' \"$fullPathThumb\"";
$result=`$str`;
However what I want to also do is "slide the sized down image some so that the upper left corner of the image is moved around, usually negative value up and negative value left, to center and crop. How would I do that? Thanks.
I am not too sure I understand your "sliding around" idea, but hopefully the following will explain how you can crop with offsets and resize. If not, please ask further questions.
Let's start with an image made of 8 blocks, each 100x100 pixels and off-square so we know which is side is which.
convert -size 100x100 \
\( xc:red xc:blue xc:green xc:black +append \) \
\( xc:cyan xc:magenta xc:yellow xc:white +append \) -append out.png
Now, we check its size is indeed 400x200:
identify out.png
out.png PNG 400x200 400x200+0+0 8-bit sRGB 8c 467B 0.000u 0:00.000
So, first we will do a simple resize, which will preserve the 2:1 aspect ratio:
convert out.png -resize 300x300 simple_resize.png
identify simple_resize.png
simple_resize.png PNG 300x150 300x150+0+0 8-bit sRGB 47c 672B 0.000u 0:00.000
Now we use the bang operator (!) to tell ImageMagick rather forcefully "Do what I said"
convert out.png -resize 300x300! simple_resize_changed_aspect.png
identify simple_resize_changed_aspect.png
simple_resize_changed_aspect.png PNG 300x300 300x300+0+0 8-bit sRGB 52c 894B 0.000u 0:00.000
And finally, we come to what is hopefully the bit you want, which is crop and resize. So let's crop an area 150 pixels wide by 100 pixels high starting 150 pixels across to the right from the top left corner and 50 pixels down from the top left corner:
convert out.png -crop 150x100+150+50 -resize 300x300 x.png
That looks right, but if we use identify we will see that ImageMagick has remembered too much about where our image came from and is considering it a part of the bigger original image:
identify x.png
x.png PNG 300x200 800x400+300+100 8-bit sRGB 30c 732B 0.000u 0:00.000
So, actually we better tell ImageMagick to reset the dimensions of the image so it is sitting on a canvas of "just the right size"... by using the +repage option on the previous command like this:
convert out.png -crop 150x100+150+50 -resize 300x300 +repage x.png
and check again
identify x.png
x.png PNG 300x200 300x200+0+0 8-bit sRGB 30c 690B 0.000u 0:00.000
That's better - probably best to use +repage whenever you crop. I hope that addresses your question, as I said, please ask further if not.

ImageMagic renders image with black background

I'm converting pdf files to images with ImageMagic, everything is ok until I use -resize option, then I get image with black background. I use this command:
convert -density 400 image.pdf -resize 25% image.png
I need to use -resize option otherwise I get really large image. Is there any other option which I can use to resize image or is there option to set background in white.
That's not a Ghostscript command, You will need to find out what convert is sending to Ghostscript. As it stands I can't even be sure that your problem is with Ghostscript ,since it could easily be something that convert is doing.
Solved it by removing alpha from image, it seems imagemagic tries to apply some opacity but since jpeg doesn't allow transperency result was black background. So I found example on imagemagic website and it helped me:
convert a.pdf -background skyblue -alpha remove -alpha off a_remove.jpg

How to convert SVG image to 32-bit RGBA with ImageMagick?

How to convert SVG image to 32-bit RGBA with ImageMagick?
Background must be transparent.
Simply try this command:
convert in.svg -transparent white out.png
(Assuming the original SVG uses a transparent or white background. Otherwise, if SVG background is red or blue or '#235689': use -transparent red, -transparent blue or -transparent '#235689'....)
If your version of ImageMagick doesn't do it right, check if convert -list configure | grep svg shows rsvg output in the DELEGATES and CONFIGURE lines.
I found that setting background to none worked for me:
convert -background none in.svg out.png

Resources