Sample Header Ad - 728x90

Unix & Linux Stack Exchange

Q&A for users of Linux, FreeBSD and other Unix-like operating systems

Latest Questions

0 votes
2 answers
46 views
For what tasks Netpbm images are used? Why 'pdfimages' use it as a default 'format' for extracted images?
> Normally, all images are written as PBM (for monochrome images), PGM (for grayscale images), or PPM (for color images) files. With this option, images in DCT format are saved as JPEG files. All non-DCT images are saved in PBM/PGM/PPM format as usual. (Inline images are always saved in PBM/PGM/PPM...
> Normally, all images are written as PBM (for monochrome images), PGM (for grayscale images), or PPM (for color images) files. With this option, images in DCT format are saved as JPEG files. All non-DCT images are saved in PBM/PGM/PPM format as usual. (Inline images are always saved in PBM/PGM/PPM format.) > > — man pdfimages from Xpdf > The default output format is PBM (for monochrome images) or PPM for non-monochrome. The -png or -tiff options change to default output to PNG or TIFF respectively. If both -png and -tiff are specified, CMYK images will be written as TIFF and all other images will be written as PNG. In addition the -j, -jp2, and -jbig2 options will cause JPEG, JPEG2000, and JBIG2, respectively, images in the PDF file to be written in their native format. > > — man pdfimages from poppler What is the reason that both implementations of pdfimages extract images in "mysterious" (I call them "mysterious" because I have never heard of them before) PBM/PGM/PPM formats (collectively known as Netpbm or PNM, https://en.wikipedia.org/wiki/Netpbm) instead of PNG, JPEG or maybe GIF, which are (I might be wrong, of course) is the de-facto standard in casual-user-world these days (and, if I recall correctly, it was the same de-facto standard 10 and 20 years ago as well)?
jsx97 (1347 rep)
Aug 3, 2024, 09:05 PM • Last activity: Aug 4, 2024, 06:10 AM
2 votes
2 answers
135 views
How to preserve PNG image type (RGB or Indexed) when converting with NetPBM?
I have a PNG image processing workflow that relies on the images to be in the 24bit Truecolor format also known as RGB images. PNG permits either RGB or Indexed color representation. The `pnmtopng` program from NetPBM automatically decides which type of image to write depending on the number of dist...
I have a PNG image processing workflow that relies on the images to be in the 24bit Truecolor format also known as RGB images. PNG permits either RGB or Indexed color representation. The pnmtopng program from NetPBM automatically decides which type of image to write depending on the number of distinct colors in the image. I recall reading somewhere that if this number is 256 or fewer, it automatically writes an Indexed image. Is there a way to preserve the type of the image? For instance if I am using NetPBM to flip an image as follows
pngtopnm true-color-image.png | pamflip -tb | pnmtopng > new-image.png
Is there a way to ensure that new-image will also be a Truecolor image? At the moment I can check that the image is of a wrong type, because its size is about 50% less than that of the original image.
37155 true-color-image.png
27463 new-image.png
I expect the new image to be about the same size as the original. Also identify from ImageMagick gives the following for these two images:
true-color-image.png PNG 300x280 300x280+0+0 8-bit sRGB 37155B
new-image.png PNG 300x280 300x280+0+0 8-bit sRGB 61c 27463B
Dima Chubarov (694 rep)
Nov 20, 2023, 04:49 PM • Last activity: Nov 25, 2023, 12:46 PM
1 votes
1 answers
103 views
tee pipeline and pnmtools - truncated file
This sequence of commands works OK: ``` pngtopnm file.png 2> /dev/null > dump1 pnmfile /dev/null | tee dump2 | pnmfile stdin: PPM raw, 1920 by 1080 maxval 255 ls -l dump2 -rw-r----- 1 cmb 49152 Sep 15 14:34 dump2 ``` I'm not clear on what difference it makes where 'tee' is sending stdin to what gets...
This sequence of commands works OK:
pngtopnm file.png 2> /dev/null > dump1
pnmfile  /dev/null | tee dump2 | pnmfile
stdin:	PPM raw, 1920 by 1080  maxval 255
ls -l dump2
-rw-r----- 1 cmb   49152 Sep 15 14:34 dump2
I'm not clear on what difference it makes where 'tee' is sending stdin to what gets saved in the dump file - why is 'dump2' truncated, and not identical to 'dump1'?
cmp dump
cmp: EOF on dump2 after byte 49152, in line 4
I suspect its something to do with 'pnmfile', since putting something else at the end of the pipeline seems to work OK - 'dump3' is the right size/same content as dump1, and the end of the pipe ('fmt') is doing something to the file...:
pngtopnm file.png 2> /dev/null  | tee dump3 |fmt -10 > dump4
ls -l dump
-rw-r----- 1 cmb 6220817 Sep 15 14:41 dump3
-rw-r----- 1 cmb 6224311 Sep 15 14:41 dump4
(XUbuntu 20.04, diffutils 3.7, Netpbm 10.0, coreutils 8.30)
ColinB (113 rep)
Sep 15, 2020, 02:00 PM • Last activity: Sep 15, 2020, 03:08 PM
3 votes
1 answers
261 views
Colour problem when capturing a png of the top panel of the screen
I want to capture a window as a png from within a bash script, using the window's *ID*. In this case, the window is the top panel.  Using `gnome-screenshot` the colours are true, as per this image... (this image is not the same size as the following image, so ignore the dark line at the bottom)...
I want to capture a window as a png from within a bash script, using the window's *ID*. In this case, the window is the top panel.  Using gnome-screenshot the colours are true, as per this image... (this image is not the same size as the following image, so ignore the dark line at the bottom) enter image description here However when I capture the panel via import, *or* xwd + convert, I get the following image.. enter image description here Why would I be getting this colour aberration? import and convert both belong to the imagemagick package... I haven't found anything else in the Ubuntu repository which can capture a window by its *ID*... so I'm stuck. (gnome-screenshot doesn't have the feature)... It would be nice to know what is going on here (eg, is is something to do with *transparent* images, which I know very little about)...but in any case, just a recommendation of a *workaround* capture utility may do the trick ... it must be able to capture a window by it's *ID*.    Here is an example of how I make and view the image capture. import -window "$(wmctrl -l |grep "Top Expanded Edge Panel" |awk '{print $1}')" screen.png display screen.png
Peter.O (33644 rep)
Jul 6, 2011, 07:45 PM • Last activity: Sep 2, 2012, 01:24 AM
2 votes
1 answers
143 views
Given a .gif, return the color components as X11-style hexadecimal specifiers (or equivalents)
I am a fan of `potrace`, and I recently read the [Potrace FAQ][1]. The FAQ includes this beautiful one-liner: cat img.gif | giftopnm | ppmcolormask #641b1b | potrace The command I am looking for would return the codes of all the colors to be parsed by `ppmcolormask`. It could return, according to `m...
I am a fan of potrace, and I recently read the Potrace FAQ . The FAQ includes this beautiful one-liner: cat img.gif | giftopnm | ppmcolormask #641b1b | potrace The command I am looking for would return the codes of all the colors to be parsed by ppmcolormask. It could return, according to man ppmcolormask: You can specify color five ways: o An X11-style color name (e.g. black). o An X11-style hexadecimal specifier: rgb:r/g/b, where r g and b are each 1- to 4-digit hexadecimal numbers. o An X11-style decimal specifier: rgbi:r/g/b, where r g and b are floating point numbers between 0 and 1. o For backwards compatibility, an old-X11-style hexadecimal num‐ ber: #rgb, #rrggbb, #rrrgggbbb, or #rrrrggggbbbb. o For backwards compatibility, a triplet of numbers separated by commas: r,g,b, where r g and b are floating point numbers between 0 and 1. (This style was added before MIT came up with the similar rgbi style.)
ixtmixilix (13520 rep)
Feb 16, 2012, 04:33 PM • Last activity: Feb 16, 2012, 05:44 PM
Showing page 1 of 5 total questions