libheif icon indicating copy to clipboard operation
libheif copied to clipboard

Exif data lost during conversion

Open abhinavkgrd opened this issue 2 years ago • 5 comments

Hello, First of all thank you so much for this awesome library

So, I have tried the demo live at https://strukturag.github.io/libheif,

I wanted to know if it is by design that the converted file does not have EXIF data

Test FIle - https://drive.google.com/file/d/1c4IDtTjdK_FAl-tDbuNVOTWjGOLyUGnU/view?usp=sharing

Thanks in advance!!

abhinavkgrd avatar Sep 12 '21 07:09 abhinavkgrd

Using heif-convert it Exif-data a composed in a sensible way (first look) Using heif-thumbnailer it does not work, because heif-thumbnailer creats png but not jpeg. I use a version 1.12.0 from Packman

hfst1 avatar Dec 05 '21 15:12 hfst1

The HEIF-ENC doesn't copy exif details from jpeg either.

I have tried conversion from JPEG to HEIC, the command: heif-enc.exe -q 50 image.jpg -o image.heif succesfully creates a heif-file, but all exif details, camera paramenters, gps coordinates are lost during the conversion.

Could you please help with this.

liero0 avatar Jan 29 '22 08:01 liero0

How to deal with this problem

ClearSeve avatar Apr 22 '22 01:04 ClearSeve

@ClearSeve and @liero0 : I have a little script which converts HEIF to jpg keeping exif-data

#!/bin/bash

tmp=`basename $0`
tmp=$tmp$$
mkdir /tmp/$tmp

USAGE="usage $0 file1 file2 ... fileN"

if [ "$#" == "0" ] ; then
        echo $USAGE
        exit 1
fi

while (( "$#" )); do
        fullheifname=$1

        #echo `dirname $fullheifname`/`basename $fullheifname .HEIC`.HEIC
        if [ -f `dirname $fullheifname`/`basename $fullheifname .HEIC`.HEIC ] ; then
                echo convert `basename $fullheifname`
                heifname=`basename $fullheifname .HEIC`
                jpgname=$heifname.jpg
                heif-convert $fullheifname /tmp/$tmp/$jpgname
                echo heif-convert executed
                jhead -ft -n%Y%m%d_%H%M%S /tmp/$tmp/$jpgname
                echo jhead executed
                # ls -alst /tmp/$tmp
                newheifname=`ls /tmp/$tmp/*.jpg`
                newheifname=`basename $newheifname .jpg`
                newheifname=$newheifname.HEIC
                mv $fullheifname `dirname $fullheifname`/$newheifname
                mv /tmp/$tmp/*.jpg `dirname $heifname`
        else
                echo $fullheifname does not exist or is not a HEIC-file
        fi

        shift
done

rm -r /tmp/$tmp

hfst1 avatar Apr 25 '22 19:04 hfst1

The encoder sample project in my libheif-sharp-samples repository preserves the EXIF and ICC metadata when encoding. Binaries can be downloaded from the releases page: https://github.com/0xC0000054/libheif-sharp-samples/releases

0xC0000054 avatar May 01 '22 13:05 0xC0000054

heif-enc should now preserve EXIF and XMP information and also respects the EXIF Orientation of the JPEG. 7a3be91dc80e4c332a0cbb141209e3ba26dad70c 280ab284086f0458703a98c791187ba728429b09 4d9f13b8e00220193dc3e0b2bcd655ca0e9fa02d

farindk avatar Oct 17 '22 18:10 farindk

Heic-Convert-installer.zip I have made a small script for the job: HeicConvert is a script which, when installed, will create an icon on your Linux desktop.

Dragging and dropping any image on the HeicConvert icon will create a heic format copy of the image in the same location as the original image. For example the file DSC02422.JPG dropped on the icon will result in the creation of another file DSC02422.heic. Exif information of the jpg file will be copied to the generated heic file.

tabishq avatar May 16 '23 06:05 tabishq

Exif and XMP are copied over to the output of heif-enc since v1.14.0. It also modifies the orientation tags since still a couple of viewers falsely use these to rotate HEIF images.

farindk avatar May 16 '23 08:05 farindk

Exif and XMP are copied over to the output of heif-enc since v1.14.0. It also modifies the orientation tags since still a couple of viewers falsely use these to rotate HEIF images.

Thanks @farindk for your quick reply. You did mention it earlier too, however v1.14.0 is still not available in Ubuntu 22.04 LTS repositories. My script can be used for drag and drop conversion to heic (it uses heif-enc). While using heif-enc v1.14.0+, the exiftool step can be commented out from the script.

tabishq avatar May 16 '23 08:05 tabishq