PDF files are vector files. But if you start with a raster file, Imagemagick will not vectorize it. It will end up being a raster file put into a vector PDF shell. So the result will be a large file size. I do not know if it can be made as small as you want. It depends upon the bit depth 8-bit vs 24-bit vs 32-bit if transparency before it is put into the PDF vector shell. Also it depends if the file is CMYK (4 channels) or RBG (3 channels) without alpha.
Also PDF files do not have sizes in MB. They are vector files and the size depends upon how you rasterize them with some specified density.
What I would do is process to extract the clip path and use it to make the background transparent. The trim the image and flatten it against white.
So if I save the result to JPG, the file size is 202 KB.
Code: Select all
identify -quiet -format "%[8BIM:1999,2998:#1]" in.jpg |\
convert -quiet in.jpg \
-profile /Users/fred/images/profiles/sRGB.icc \
\( -density 96 - -channel rgb -negate +channel \) \
-alpha off -compose copy_opacity -composite \
-trim +repage -background white -compose over -flatten \
result.jpg
But you can save to PDF, but it won't show any file size in KB or MB.
Code: Select all
identify -quiet -format "%[8BIM:1999,2998:#1]" in.jpg |\
convert -quiet in.jpg \
-profile /Users/fred/images/profiles/sRGB.icc \
\( -density 96 - -channel rgb -negate +channel \) \
-alpha off -compose copy_opacity -composite \
-trim +repage -background white -compose over -flatten \
result.pdf