ExifTool Forum

ExifTool => Newbies => Topic started by: dle001 on June 20, 2021, 12:14:56 PM

Title: Get "Error: Not a valid PNG" when tagsfromfile json
Post by: dle001 on June 20, 2021, 12:14:56 PM
Hi

I'm trying to transfer datas from 3,000.json files to 3,000 image files (Google Photo Takeout) by using exiftool with this command

exiftool.exe -r -d %s -tagsfromfile "%d/%F.json" "-GPSAltitude<GeoDataAltitude" "-GPSLatitude<GeoDataLatitude" "-GPSLatitudeRef<GeoDataLatitude" "-GPSLongitude<GeoDataLongitude" "-GPSLongitudeRef<GeoDataLongitude" "-Keywords<Tags" "-Subject<Tags" "-Caption-Abstract<Description" "-ImageDescription<Description" "-DateTimeOriginal<PhotoTakenTimeTimestamp" -ext "*" -overwrite_original -progress --ext json D:\Program.portable\exiftool-12.27\Newfolder

After That, I got the Error massage.

Error: Not a valid PNG (looks more like a JPEG)

How to bypass/ignore or fix it ?

Thank you
Title: Re: Get "Error: Not a valid PNG" when tagsfromfile json
Post by: StarGeek on June 20, 2021, 12:17:22 PM
The error tells you what the problem is.  It has a .PNG extension but the file is a jpeg and should have a .JPG extension.  Rename it.
Title: Re: Get "Error: Not a valid PNG" when tagsfromfile json
Post by: dle001 on June 20, 2021, 09:04:16 PM
Quote from: StarGeek on June 20, 2021, 12:17:22 PM
The error tells you what the problem is.  It has a .PNG extension but the file is a jpeg and should have a .JPG extension.  Rename it.

Oh I can not rename all of files bacuse there are 3,000 image files.

Do you have easy way to rename all ?
Title: Re: Get "Error: Not a valid PNG" when tagsfromfile json
Post by: StarGeek on June 21, 2021, 12:38:33 AM
exiftool -ext png "-filename<%f.$fileTypeExtension" /path/to/files/

This will check all PNG files and rename them if they need to be renamed.
Title: Re: Get "Error: Not a valid PNG" when tagsfromfile json
Post by: MrSimmo on April 06, 2025, 02:16:55 AM
Just a quick update - I found the above command failing under Linux. Changed it to:

exiftool -ext 'png' '-FileName<%f.$FileTypeExtension' [path]

and it worked
Title: Re: Get "Error: Not a valid PNG" when tagsfromfile json
Post by: StarGeek on April 06, 2025, 10:51:34 AM
Yes, the fact that you need to put single quotes around anything with a dollar sign on Mac/Linux has been mentioned (*checks stats*) 23,486 times in these forums. Every time that Phil posts an answer. This is due to the differences between Windows CMD and Mac/Linux command lines.