Using the exiftool library from php (in place of native php function)

Started by Herbert, February 02, 2025, 10:37:49 AM

Previous topic - Next topic

Herbert

Hi, I'm a newbie with some questions.

I have a lot of images in .png-Format with IPTC-Information written with GraphicConverter and first converted to .jpg-Format for displaying as webgalleries created with PHP and displayed these IPTC-Informations as caption.The readout of the IPTC-Data with the PHP-builtin-Function iptcparse() works fine for JPEG-Images but not for JPEG XL-Images.
I want now convert the PNG-Format Images to lossless JPEG XL-Images for the archive and for displaying these Images as webgalleries, I want use the JPEG XL lossy Format.
I tested images after converted to JPEG XL-Format in GraphicConverter and the IPTC-data are still in the image-file.
Now I want to readout the IPTC-Info from JPEG XL-Images in a PHP-Programm, using the ExifTool-Library with output in a PHP-array and select some infos for display the caption with that image on a website.

How can i call the ExifTool-Library from PHP with which parameters to get this IPTC-informations?

Phil Harvey

You should be able to execute an external command from PHP, or there are a couple of PHP interfaces here

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

StarGeek

Quote from: Herbert on February 02, 2025, 10:37:49 AMHow can i call the ExifTool-Library from PHP with which parameters to get this IPTC-informations?

Any PHP wrapper for exiftool is a third party library. We can help with a command on the command line, but have no knowledge on how to implement it in third party code.

And to clarify, IPTC data cannot be written to JPEGXL and is non-standard in PNG files. What you probably want to look at is XMP data, which is where IPTC Core/Ext data is written.
"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

Herbert

Quote from: StarGeek on February 02, 2025, 01:07:21 PMAny PHP wrapper for exiftool is a third party library. We can help with a command on the command line, but have no knowledge on how to implement it in third party code.

And to clarify, IPTC data cannot be written to JPEGXL and is non-standard in PNG files. What you probably want to look at is XMP data, which is where IPTC Core/Ext data is written.

I have tested it on a Mac with GraphicConverter (see above) and then read it from a JPEG XJ (.jxl)-Image with ExifTool Reader. It works perfect, but I need this information not in an extra file whether as XMP-File nor as Excel-File but want to read it in a PHP-program direct from the image.

Thank you Phil for your tipp to PHP-interfaces. I will research for further informations how they work and where I can get one.

If I've got a good solution for my problem, I will report it here for other users with the same problem because I think that the JPEG XL-format really new but is the best successor for the good old JPEG-format so every work with this format is worth it.   

 

Phil Harvey

If all you want to do is read the metadata, this example from the exiftool application -php option documentation shows simple way to get information in a format that can be used in PHP.

                <?php
                eval('$array=' . `exiftool -php -q image.jpg`);
                print_r($array);
                ?>

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