News:

2023-03-15 Major improvements to the new Geolocation feature

Main Menu

pgm

Started by adammaj1, May 24, 2020, 09:40:21 AM

Previous topic - Next topic

adammaj1

Hi,

I create pgm files in c :
https://gitlab.com/adammajewski/SepalsOfCauliflower

If I check it :

exiftool 2007.0.pgm


ExifTool Version Number         : 10.80
File Name                       : 2007.0.pgm
Directory                       : .
File Size                       : 3.8 MB
File Modification Date/Time     : 2020:05:24 10:40:19+02:00
File Access Date/Time           : 2020:05:24 10:40:21+02:00
File Inode Change Date/Time     : 2020:05:24 10:40:19+02:00
File Permissions                : rw-r--r--
Error                           : File format error


I have to convert it to png usnig ImageMagic to see the comment :



convert 2007.0.pgm 2007_0.png
exiftool 2007_0.png

the result:

ExifTool Version Number         : 10.80
File Name                       : 2007_0.png
Directory                       : .
File Size                       : 294 kB
File Modification Date/Time     : 2020:05:24 15:24:10+02:00
File Access Date/Time           : 2020:05:24 15:24:10+02:00
File Inode Change Date/Time     : 2020:05:24 15:24:10+02:00
File Permissions                : rw-r--r--
File Type                       : PNG
File Type Extension             : png
MIME Type                       : image/png
Image Width                     : 2000
Image Height                    : 2000
Bit Depth                       : 8
Color Type                      : Grayscale
Compression                     : Deflate/Inflate
Filter                          : Adaptive
Interlace                       : Noninterlaced
Gamma                           : 2.2
Background Color                : 255
Modify Date                     : 2020:05:24 13:24:10
Comment                         :   Julia set , name = iHeight+anglMultiplier.
Datecreate                      : 2020-05-24T08:40:19+00:00
Datemodify                      : 2020-05-24T08:40:19+00:00
Image Size                      : 2000x2000
Megapixels                      : 4.0


Can I do it better?

TIA

Adam

StarGeek

Can you share an example file?  None of the images in your link are PGM files, they're all PNG files.

Also, have you tried a newer version of ExifTool?  The version you're using is over two years old.
* Did you read FAQ #3 and use the command listed there?
* Please use the Code button for exiftool code/output.
 
* Please include your OS, Exiftool version, and type of file you're processing (MP4, JPG, etc).

adammaj1

1. Here is my file ( pgm included)
2. Install:


sudo apt-get install -y exiftool
Czytanie list pakietów... Gotowe
Budowanie drzewa zależności       
Odczyt informacji o stanie... Gotowe
Uwaga, wybieranie "libimage-exiftool-perl" zamiast "exiftool"
libimage-exiftool-perl is already the newest version (10.80-1).
0 aktualizowanych, 0 nowo instalowanych, 0 usuwanych i 39 nieaktualizowanych.


I will try other method to have latest version

StarGeek

Unfortunately, not much better result with a newer version.  Any version before 11.75 returns a File format error while versions 11.75 on treat it as a text file.  Imagemagick correctly identifies it as a PGM file.

This will be something Phil will have to look into.

* Did you read FAQ #3 and use the command listed there?
* Please use the Code button for exiftool code/output.
 
* Please include your OS, Exiftool version, and type of file you're processing (MP4, JPG, etc).

Phil Harvey

Thanks for the sample.  I think the problem may be the type of linefeeds used in this file, but I should be able to fix this for the next ExifTool release.

- Phil
...where DIR is the name of a directory/folder containing the images.  On Mac/Linux/PowerShell, use single quotes (') instead of double quotes (") around arguments containing a dollar sign ($).

adammaj1

file 2007.0.pgm

result:
2007.0.pgm: Netpbm image data, size = 2000 x 2000, rawbits, greymap

check newline char ( https://stackoverflow.com/questions/20674513/using-find-command-in-unix-to-search-for-a-newline ):

grep -P '$' 2007.0.pgm

result:

P5
#  Julia set , name = iHeight+anglMultiplier
2000 2000
255
Plik binarny 2007.0.pgm pasuje do wzorca



I see spaces in some lines. It is because of my ( bad) code

fprintf (fp, "P5\n # %s\n %u %u\n %u\n", comment, iWidth, iHeight, MaxColorComponentValue); /*write header to the file */

I will remove spaces by changing my c code to :

fprintf (fp, "P5\n# %s\n%u %u\n%u\n", long_comment, iWidth, iHeight, MaxColorComponentValue); /*write header to the file */

New file seems better:


exiftool 2001.0.pgm

result:


ExifTool Version Number         : 10.80
File Name                       : 2001.0.pgm
Directory                       : .
File Size                       : 3.8 MB
File Modification Date/Time     : 2020:05:27 09:05:32+02:00
File Access Date/Time           : 2020:05:27 09:04:56+02:00
File Inode Change Date/Time     : 2020:05:27 09:05:32+02:00
File Permissions                : rw-r--r--
File Type                       : PGM
File Type Extension             : pgm
MIME Type                       : image/x-portable-graymap
Comment                         :  Julia set: interior  , name = iHeight + AK.AK = 1. angleMultiplier = 7
Image Width                     : 2000
Image Height                    : 2000
Max Val                         : 255
Image Size                      : 2000x2000
Megapixels                      : 4.0


So it looks that the problem was caused by unnecessary space at the beginoing of the lines


Phil Harvey

Yes, it was the extra space that caused the problem.  But I think this is allowd according to the PPM specification, so ExifTool 12.00 will allow this.

- Phil
...where DIR is the name of a directory/folder containing the images.  On Mac/Linux/PowerShell, use single quotes (') instead of double quotes (") around arguments containing a dollar sign ($).