# HG changeset patch # User Matti Hamalainen # Date 1585214133 -7200 # Node ID b72da68991edff3d2990d785158e748ebe2e3cc7 # Parent 7bccb4204e6ea08adb7f998fe54f6e7b3b5fd7a0 Improve few comments. diff -r 7bccb4204e6e -r b72da68991ed mgtool.php --- a/mgtool.php Thu Mar 26 10:54:51 2020 +0200 +++ b/mgtool.php Thu Mar 26 11:15:33 2020 +0200 @@ -118,6 +118,7 @@ $dim = $img->getImageGeometry(); $img->setGravity(imagick::GRAVITY_CENTER); + // Width smaller than height? Swap dimensions if ($dim["width"] < $dim["height"]) { $stmp = $outDim[0]; @@ -125,6 +126,7 @@ $outDim[1] = $stmp; } + // Compute new height if needed if ($dim["width"] != $outDim[0] || $dim["height"] != $outDim[1]) { $outDim[1] = ($dim["height"] * $outDim[0]) / $dim["width"]; @@ -192,6 +194,7 @@ $dim = $img->getImageGeometry(); //$img->setGravity(Gmagick::GRAVITY_CENTER); + // Compute new height if needed if ($dim["width"] < $dim["height"]) { $stmp = $outDim[0]; @@ -199,6 +202,7 @@ $outDim[1] = $stmp; } + // Compute new height if needed if ($dim["width"] != $outDim[0] || $dim["height"] != $outDim[1]) { $outDim[1] = ($dim["height"] * $outDim[0]) / $dim["width"]; @@ -246,8 +250,8 @@ // -// Read and parse XMP data from given file -// .. a horrible hack. +// Read XMP data block from given file +// .. it's a horrible hack. // function mgReadXMPData($filename, $xmpBlockSize = 1024*64) { @@ -348,8 +352,7 @@ if (($xmpOb = @simplexml_load_string($xmpStr)) === FALSE) return FALSE; - // Process structure to simple flat array of data - // for the desired elements only + // Process structure to simple flat array of data for the desired elements only $xmpData = []; //if (($tmp = $xmpOb->xpath("RDF/Description/description/li")) !== FALSE) @@ -966,7 +969,7 @@ $updFlags |= GUPD_CAPTION; // Check for XMP info - // TODO XXX: Support XMP sidecar files + // TODO XXX: Perhaps support XMP sidecar files if (($updFlags & GUPD_EXIF_INFO) && ($xmpStr = mgReadXMPData($efilename)) !== FALSE && ($xmp = mgParseXMPData($xmpStr)) !== FALSE)