From Newsgroup: comp.os.linux.misc
I'm seeing reports that the imagemagick module for PHP 7 could read XMP
tags (
https://en.wikipedia.org/wiki/Extensible_Metadata_Platform ) from
jpegs, but PHP 8 / mod imagick, at least as packaged by Debian, cannot.
I have personally verified the the Debian PHP 8 cannot read XMP tags,
code and output below for this test image, which has XMP data added by
the commandline exiftool, on Debian.
https://qaz.wtf/tmp/phonebag.jpg
(thumbnail sized image, with metadata copied from fullsize)
My questions, before I file bug reports:
Is this a regression? I don't have older versions to test myself.
Is there a documented reason for excluding XMP now? Maybe some security
thing?
I also don't know if this is an Imagemagick bug or a Imagemagick as
packaged by Debian bug. I've verified the 'identify' tool in the
Imagemagick package produces the same results as I see in PHP, and the Imagemagick code implies XMP data should work.
MagickCore/property.c line 1828:
static void GetXMPProperty(const Image *image,const char *property)
Looks like a fully fleshed out get and parse XMP XML implementation.
The reason I want specifically the PHP route to work is for a gallery
tool written in PHP.
Metadata seen by exiftool:
ExifTool Version Number : 13.25
File Name : phonebag.jpg
Directory : /tmp
File Size : 31 kB
File Modification Date/Time : 2026:02:02 11:42:38-08:00
File Access Date/Time : 2026:02:02 12:06:46-08:00
File Inode Change Date/Time : 2026:02:02 11:42:38-08:00
File Permissions : -rw-rw-r--
File Type : JPEG
File Type Extension : jpg
MIME Type : image/jpeg
JFIF Version : 1.01
Exif Byte Order : Big-endian (Motorola, MM)
Image Description :
Make : Unihertz
Camera Model Name : Jelly Max
Orientation : Horizontal (normal)
X Resolution : 72
Y Resolution : 72
Resolution Unit : inches
Software : MediaTek Camera Application
Modify Date : 2026:02:01 12:13:51
Y Cb Cr Positioning : Centered
Exposure Time : 1/50
F Number : 1.7
Exposure Program : Program AE
ISO : 398
Sensitivity Type : ISO Speed
Recommended Exposure Index : 0
Exif Version : 0220
Date/Time Original : 2026:01:26 21:22:42
Create Date : 2026:01:26 21:22:42
Components Configuration : Y, Cb, Cr, -
Shutter Speed Value : 1/50
Aperture Value : 1.7
Brightness Value : 0.8
Exposure Compensation : -1/2
Max Aperture Value : 1.7
Metering Mode : Center-weighted average
Light Source : Other
Focal Length : 5.2 mm
User Comment : Yaw:36.949326,Pitch:-10.665366044603356,Roll:-5.873881337506418
Sub Sec Time : 307
Sub Sec Time Original : 307
Sub Sec Time Digitized : 307
Flashpix Version : 0100
Color Space : sRGB
Exif Image Width : 4096
Exif Image Height : 3072
Exposure Mode : Auto
White Balance : Auto
Digital Zoom Ratio : 1
Focal Length In 35mm Format : 0 mm
Scene Capture Type : Standard
GPS Version ID : 2.3.0.0
GPS Img Direction Ref : Magnetic North
GPS Img Direction : 36.95
XMP Toolkit : Image::ExifTool 13.25
Description : Purse in a store window with an appliqué phone dial and telephone handset as handle.
Subject : handbag, faux, phone, store window
Title : Hand Bag Set
Flash Fired : False
Flash Function : False
Flash Mode : Off
Flash Red Eye Mode : False
Flash Return : No return detection
Interoperability Index : R98 - DCF basic file (sRGB)
Compression : JPEG (old-style)
Image Width : 320
Image Height : 279
Encoding Process : Baseline DCT, Huffman coding
Bits Per Sample : 8
Color Components : 3
Y Cb Cr Sub Sampling : YCbCr4:2:0 (2 2)
Aperture : 1.7
Image Size : 320x279
Megapixels : 0.089
Shutter Speed : 1/50
Create Date : 2026:01:26 21:22:42.307
Date/Time Original : 2026:01:26 21:22:42.307
Modify Date : 2026:02:01 12:13:51.307
Flash : Off, Did not fire
Focal Length : 5.2 mm
Light Value : 5.2
Note the "Description", "Subject", and "Title", which are in the XMP data. (Verifable with a hex editor on the image I have linked above.)
Exif reported using PHP exif_read_data():
Array
(
[FileName] => phonebag.jpg
[FileDateTime] => 1770061840
[FileSize] => 30800
[FileType] => 2
[MimeType] => image/jpeg
[SectionsFound] => ANY_TAG, IFD0, EXIF, GPS
[COMPUTED] => Array
(
[html] => width="320" height="279"
[Height] => 279
[Width] => 320
[IsColor] => 1
[ByteOrderMotorola] => 1
[ApertureFNumber] => f/1.7
[UserComment] => Yaw:36.949326,Pitch:-10.665366044603356,Roll:-5.873881337506418
[UserCommentEncoding] => ASCII
)
[ImageDescription] =>
[Make] => Unihertz
[Model] => Jelly Max
[Orientation] => 1
[XResolution] => 72/1
[YResolution] => 72/1
[ResolutionUnit] => 2
[Software] => MediaTek Camera Application
[DateTime] => 2026:02:01 12:13:51
[YCbCrPositioning] => 1
[Exif_IFD_Pointer] => 242
[GPS_IFD_Pointer] => 804
[ExposureTime] => 1/50
[FNumber] => 17/10
[ExposureProgram] => 2
[ISOSpeedRatings] => 398
[UndefinedTag:0x8830] => 3
[UndefinedTag:0x8832] => 0
[ExifVersion] => 0220
[DateTimeOriginal] => 2026:01:26 21:22:42
[DateTimeDigitized] => 2026:01:26 21:22:42
[ComponentsConfiguration] =>
[ShutterSpeedValue] => 11299/2002
[ApertureValue] => 8747/5713
[BrightnessValue] => 4/5
[ExposureBiasValue] => -1/2
[MaxApertureValue] => 8747/5713
[MeteringMode] => 2
[LightSource] => 255
[FocalLength] => 26/5
[UserComment] => ASCIIYaw:36.949326,Pitch:-10.665366044603356,Roll:-5.873881337506418
[SubSecTime] => 307
[SubSecTimeOriginal] => 307
[SubSecTimeDigitized] => 307
[FlashPixVersion] => 0100
[ColorSpace] => 1
[ExifImageWidth] => 4096
[ExifImageLength] => 3072
[ExposureMode] => 0
[WhiteBalance] => 0
[DigitalZoomRatio] => 1/1
[FocalLengthIn35mmFilm] => 0
[SceneCaptureType] => 0
[GPSVersion] =>
[GPSImgDirectionRef] => M
[GPSImgDirection] => 739/20
)
No XMP.
Exif using the imagick module in PHP:
date:create => 2026-02-02T19:50:40+00:00
date:modify => 2026-02-02T19:50:40+00:00
date:timestamp => 2026-02-02T20:10:55+00:00
exif:ApertureValue => 8747/5713
exif:BrightnessValue => 4/5
exif:ColorSpace => 1
exif:ComponentsConfiguration => ...
exif:DateTime => 2026:02:01 12:13:51
exif:DateTimeDigitized => 2026:01:26 21:22:42
exif:DateTimeOriginal => 2026:01:26 21:22:42
exif:DigitalZoomRatio => 1/1
exif:ExifOffset => 242
exif:ExifVersion => 0220
exif:ExposureBiasValue => -1/2
exif:ExposureMode => 0
exif:ExposureProgram => 2
exif:ExposureTime => 1/50
exif:FlashPixVersion => 0100
exif:FNumber => 17/10
exif:FocalLength => 26/5
exif:FocalLengthIn35mmFilm => 0
exif:GPSImgDirection => 739/20
exif:GPSImgDirectionRef => M
exif:GPSInfo => 804
exif:GPSVersionID => ....
exif:ImageDescription =>
exif:LightSource => 255
exif:Make => Unihertz
exif:MaxApertureValue => 8747/5713
exif:MeteringMode => 2
exif:Model => Jelly Max
exif:Orientation => 1
exif:PhotographicSensitivity => 398
exif:PixelXDimension => 4096
exif:PixelYDimension => 3072
exif:RecommendedExposureIndex => 0
exif:ResolutionUnit => 2
exif:SceneCaptureType => 0
exif:SensitivityType => 3
exif:ShutterSpeedValue => 11299/2002
exif:Software => MediaTek Camera Application
exif:SubSecTime => 307
exif:SubSecTimeDigitized => 307
exif:SubSecTimeOriginal => 307
exif:UserComment => ASCII
exif:WhiteBalance => 0
exif:XResolution => 72/1
exif:YCbCrPositioning => 1
exif:YResolution => 72/1
exifEX:InteroperabilityIndex => R98
jpeg:colorspace => 2
jpeg:sampling-factor => 2x2,1x1,1x1
tiff:Compression => 6
tiff:ImageLength => 1894
tiff:ImageWidth => 2173
tiff:YCbCrPositioning => 2
xmp:Flash => 0
Versions of software used:
$ grep VERSION /etc/os-release
VERSION_ID="13"
VERSION="13 (trixie)"
VERSION_CODENAME=trixie
DEBIAN_VERSION_FULL=13.3
$ apt list --installed |egrep 'magick|php[^/]*common|exiftool'
WARNING: apt does not have a stable CLI interface. Use with caution in
scripts.
imagemagick-7-common/stable-security,now 8:7.1.1.43+dfsg1-1+deb13u5 all [installed,automatic]
imagemagick-7.q16/stable-security,now 8:7.1.1.43+dfsg1-1+deb13u5 amd64 [installed,automatic]
imagemagick/stable-security,now 8:7.1.1.43+dfsg1-1+deb13u5 amd64 [installed] libimage-exiftool-perl/stable,now 13.25+dfsg-1 all [installed] libmagickcore-7.q16-10-extra/stable-security,now 8:7.1.1.43+dfsg1-1+deb13u5 amd64 [installed,automatic]
libmagickcore-7.q16-10/stable-security,now 8:7.1.1.43+dfsg1-1+deb13u5 amd64 [installed,automatic]
libmagickwand-7.q16-10/stable-security,now 8:7.1.1.43+dfsg1-1+deb13u5 amd64 [installed,automatic]
php-common/stable,now 2:96 all [installed]
php8.4-common/stable-security,now 8.4.16-1~deb13u1 amd64 [installed,automatic] php8.4-imagick/stable,now 3.8.0-2 amd64 [installed]
Here's the PHP code to show the image metadata:
<?php
// +-----------------------------------------------------------------------+
// | This file is part of Piwigo. |
// | |
// | For copyright and license information, please view the COPYING.txt |
// | file that was distributed with this source code. |
// +-----------------------------------------------------------------------+
// The next line has been changed from the Piwigo original
$filename = 'phonebag.jpg';
echo 'Informations are read from '.$filename.'<br><br><br>';
/**
* return a cleaned IPTC value
*
* @param string value
* @return string
*/
function clean_iptc_value($value)
{
// strip leading zeros (weird Kodak Scanner software)
while ( isset($value[0]) and $value[0] == chr(0))
{
$value = substr($value, 1);
}
// remove binary nulls
$value = str_replace(chr(0x00), ' ', $value);
return $value;
}
$iptc_result = array();
$imginfo = array();
getimagesize($filename, $imginfo);
if (isset($imginfo['APP13']))
{
$iptc = iptcparse($imginfo['APP13']);
if (is_array($iptc))
{
foreach (array_keys($iptc) as $iptc_key)
{
if (isset($iptc[$iptc_key][0]))
{
if ($iptc_key == '2#025')
{
$value = implode(
',',
array_map(
'clean_iptc_value',
$iptc[$iptc_key]
)
);
}
else
{
$value = clean_iptc_value($iptc[$iptc_key][0]);
}
$iptc_result[$iptc_key] = $value;
}
}
}
echo 'IPTC Fields in '.$filename.'<br>';
$keys = array_keys($iptc_result);
sort($keys);
foreach ($keys as $key)
{
echo '<br>'.$key.' = '.$iptc_result[$key];
}
}
else
{
echo 'no IPTC information';
}
echo '<br><br><br>';
echo 'EXIF Fields in '.$filename.'<br>';
$exif = exif_read_data($filename);
echo '<pre>';
print_r($exif);
echo '</pre>';
#
# Display XMP metadata using ImageMagick PHP extension
#
print "<h3>XMP data in '{$filename}'</h3><br />" ;
print ' (Requires Imagemagick PHP extension)<br />' ;
print '<pre>' ;
if( extension_loaded('imagick') && class_exists("Imagick") ){ //Check ImageMagick is installed
// create new Imagick object from image
$sampleIM = new imagick($filename) ;
// get the XMP data
// The next line has been changed from the Piwigo original
$sampleXMP = $sampleIM -> getImageProperties("*") ;
// If there's data, then loop through the XMP array
if ( count($sampleXMP) ) {
foreach ($sampleXMP as $XMPname => $XMPproperty) {
print "{$XMPname} => {$XMPproperty} <br />\n" ;
}
}else{
print 'No data <br /> ';
}
print '[end of XMP]' ;
}else{
print 'ImageMagick not detected or disabled' ;
}
print '</pre>' ;
There is a Piwigo forum, but this issue doesn't seem to be in Piwigo's
code, so they don't seem capable of helping.
Elijah
------
very few gallery tools support image tags, Piwigo is one
--- Synchronet 3.21b-Linux NewsLink 1.2