Menalto Gallery GdFunctionality.class fix

When upgrading from PHP 5.2 to a newer 5.x version, Menalto’s Gallery resulted in the following error:

Warning: Missing argument 3 for GdFunctionality::imageJpeg(), called in /home/userdir/public_html/gallery2/modules/gd/classes/GdToolkit.class on line 527 and defined in /home/userdir/public_html/gallery2/modules/gd/classes/GdFunctionality.class on line 351

Rather than just turning off warnings, I fixed it with the following code segment:

Edit file:¬†gallery2/modules/gd/classes/GdToolkit.class, around line 527, you’ll find:

$ret = $gd->imageJpeg($tmpRes, $tmpFile);

Replace with:

            list ($ret, $jpegQuality) = GalleryCoreApi::getPluginParameter('module', 'gd', 'jpegQuality');
            if ($ret) {
                return $jpegQuality = 90;
            }
            $ret = $gd->imageJpeg($tmpRes, $tmpFile, $jpegQuality);

What it does: the replacement code attempts to get the default quality set for the album in which one is uploading. If successful, that setting is used. If unsuccessful, a default value of 90 is used. Feel free to change the default value of 90 to something between 1 and 100.

Leave a Reply

Your email address will not be published. Required fields are marked *