Delete all meta except jfif

Started by ranger, May 08, 2020, 10:47:56 AM

Previous topic - Next topic

ranger

Hi,

I have an application that requires me to use jpeg files without exif meta data.
Therefore, I used  exiftool -all= ./img.jpg  and  exiftool -exif:all= ./image.jpg  to delete it.

Now the problem is the app complains that in this file, the APP0 marker is missing.
This app has to automatically process the jpg file, more exactly to save it as TIFF
and it seems it needs some meta data in order to be able to do that, but such data is deleted too.

So I tried this approach:
exiftool -exif:all= --jfif:all ./img.jpg
exiftool -exif:all= -tagsfromfile @ -*Resolution ./img.jpg

but none work.

So question is how to delete the exif data but keep the needed meta info.

Any hints are appreciated.

StarGeek

The command you list doesn't remove the JFIF block, it only clears the EXIF block.
Example:
C:\>exiftool -g1 -a -s -exif:all -jfif:all Y:/!temp/st/test.jpg
---- JFIF ----
JFIFVersion                     : 1.01
ResolutionUnit                  : inches
XResolution                     : 72
YResolution                     : 72
---- IFD0 ----
Model                           : test
XResolution                     : 72
YResolution                     : 72
ResolutionUnit                  : inches
YCbCrPositioning                : Centered

C:\>exiftool -P -overwrite_original -exif:all= Y:/!temp/st/test.jpg
    1 image files updated

C:\>exiftool -g1 -a -s -exif:all -jfif:all Y:/!temp/st/test.jpg
---- JFIF ----
JFIFVersion                     : 1.01
ResolutionUnit                  : inches
XResolution                     : 72
YResolution                     : 72


Maybe you mean you want to remove all the EXIF data except the resolution tags?  In that case you were close with your second command, you probably just needed to include the ResolutionUnit as well

C:\>exiftool -g1 -a -s -exif:all -jfif:all Y:/!temp/st/test.jpg
---- JFIF ----
JFIFVersion                     : 1.01
ResolutionUnit                  : inches
XResolution                     : 72
YResolution                     : 72
---- IFD0 ----
Model                           : test
XResolution                     : 72
YResolution                     : 72
ResolutionUnit                  : inches
YCbCrPositioning                : Centered

C:\>exiftool -P -overwrite_original -exif:all= -TagsFromFile @ -*resolution* Y:/!temp/st/test.jpg
    1 image files updated

C:\>exiftool -g1 -a -s -exif:all -jfif:all Y:/!temp/st/test.jpg
---- JFIF ----
JFIFVersion                     : 1.01
ResolutionUnit                  : inches
XResolution                     : 72
YResolution                     : 72
---- IFD0 ----
XResolution                     : 72
YResolution                     : 72
ResolutionUnit                  : inches
YCbCrPositioning                : Centered


Or maybe the JFIF block didn't exist in the first place?  In that case, you can recreate it with something like
exiftool -JFIF:*Resolution=300 -ResolutionUnit=Inches /path/to/file/

Also, be aware that none of these commands will remove metadata that is in the XMP or IPTC groups.
"It didn't work" isn't helpful. What was the exact command used and the output.
Read FAQ #3 and use that cmd
Please use the Code button for exiftool output

Please include your OS/Exiftool version/filetype

ranger

Thanks for the reply.
I just assumed it deleted resolution too and tried to keep it alive thinking it would fix the issue but it didn't work (it was just my assumption).

What is for sure is that the app returns the error message "APP0 marker is missing" and that it required JFIF

Is there any way to accomplish this?   (delete exif data and keep JFIF data)

StarGeek

None of the above commands, yours or mine, delete the JFIF data.  Are you sure it existed in the first place?  Check the file out before and after with
exiftool -JFIF:all /path/to/file

If exiftool says it has the JFIF block and the program says it's missing, then the program is giving a misleading error and requires some other piece of data. 
"It didn't work" isn't helpful. What was the exact command used and the output.
Read FAQ #3 and use that cmd
Please use the Code button for exiftool output

Please include your OS/Exiftool version/filetype

ranger

When I run this in cmd on original file  (exiftool -JFIF:all /path/to/file)  there is no data returned...

If it is possible to create a new JFIF block with at least the APP0 marker (holding even empty or dummy values, but just to be there), I would like to try that too...

Phil Harvey

You may create a new JFIF segment like this:

exiftool -jfif:xresolution=72 FILE

- 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 ($).

ranger

Thanks; after deleting all exif data, I ran this command but the file wasn't updated. The message I get is:
Warning: Not creating JFIF in JPEG with Adobe APP14 - FILE

StarGeek

See this thread.  Basically, since the image already has an Adobe APP14 block, adding a JFIF block might cause the image to be improperly rendered.

Here's the example images from that thread.  The first is the original


Then when the JFIF is added when there is an Adobe APP14 block already in the image.

"It didn't work" isn't helpful. What was the exact command used and the output.
Read FAQ #3 and use that cmd
Please use the Code button for exiftool output

Please include your OS/Exiftool version/filetype

Phil Harvey

@StarGeek:  Nice digging to find that old thread!

- 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 ($).

ranger

Thanks, that is quite interesting.

It's true, I'm using Photoshop to create/save the files.
So if the file is made with Adobe, it can't be converted to jfif by any means..?

Actually, I've got some more concrete feedback about the needed file.
And these are the only mandatory specifications:
- Must be JFIF
- Must have APP0 marker
- Must NOT have markers APP1-APP15

Can't marker 15 be deleted entirely?

Phil Harvey

Do you mean APP14?  Delete this with -adobe:all=

- 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 ($).

ranger

OK, please check the attached file img_orig.jpg.
I applied these actions:
-exif:all=
-adobe:all=
-JFIF:xresolution=72

and in the end I got the file  img_done.jpg

Then they tell me that the image still contains markers APP13, APP1, APP2

Isn't there a way to clear all these markers (except APP0), in one go?

Phil Harvey

To delete all but JFIF, do this: -all= -adobe:all= --jfif:all

- 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 ($).

ranger

Thank you, it seems I'm closer now.
The only error I get now is that "APP0 marker is missing"  .

Is it possible to avoid deleting of only this marker, or, to re-create it again after deleting all...?

Phil Harvey

The APP0 marker is the JFIF segment.  I have already shown you a command that will recreate 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 ($).