Author Topic: [1.7 / 1.7.1] PHP v5.1.x and PNG images error  (Read 35968 times)

0 Members and 1 Guest are viewing this topic.

Offline V@no

  • If you don't tell me what to do, I won't tell you where you should go :)
  • Global Moderator
  • 4images Guru
  • *****
  • Posts: 17.849
  • mmm PHP...
    • View Profile
    • 4images MODs Demo
[1.7 / 1.7.1] PHP v5.1.x and PNG images error
« on: February 25, 2006, 10:26:48 AM »
Since PHP v5.1 the GD function imagepng() accepts compression argument. The compression argument must be from 0 to 9. 4images is using the compression settings when creating thumbnails or image resizing for jpeg images which can be from 0 to 100. Because of that using imagepng() function will return fatal error
Quote
PHP Fatal error: imagepng() [<a href='function.imagepng'>function.imagepng</a>]: gd-png: fatal libpng error: zlib error in example.php on line 10

The fix is simple:
In includes/image_utils.php find:
Code: [Select]
    $image_handle = "image".$types[$image_info[2]];
Insert below:
Code: [Select]
    if ($image_info[2] == 3) $quality = 9;
Your first three "must do" before you ask a question:
Please do not PM me asking for help unless you've been specifically asked to do so. Such PMs will be deleted without answer. (forum rule #6)
Extension for Firefox/Thunderbird: Master Password+    Back/Forward History Tweaks (restartless)    Cookies Manager+    Fit Images (restartless for Thunderbird)

Offline Sunny C.

  • Addicted member
  • ******
  • Posts: 1.805
  • I ♥ 4I
    • View Profile
Re: [1.7 / 1.7.1] PHP v5.1.x and PNG images error
« Reply #1 on: March 16, 2010, 10:00:51 PM »
Member Upload work with png fix
ACP Upload dont work with png fix

Image file uploaded: bioshock2_details.png
Error while uploading the thumbnail image: bioshock2_thumbnail.png
bioshock2_details.png: The file has an invalid format (png, image / png)

Image file deleted
Data not written to the database

----

Bild-Datei erfolgreich upgeloadet: bioshock2_details.png
Fehler beim Upload der Thumbnail-Bilddatei: bioshock2_thumbnail.png
bioshock2_details.png: Die Datei hat ein ungültiges Format (png, image/png)

Bild-Datei wieder gelöscht
Daten nicht in die Datenbank geschrieben


Offline V@no

  • If you don't tell me what to do, I won't tell you where you should go :)
  • Global Moderator
  • 4images Guru
  • *****
  • Posts: 17.849
  • mmm PHP...
    • View Profile
    • 4images MODs Demo
Your first three "must do" before you ask a question:
Please do not PM me asking for help unless you've been specifically asked to do so. Such PMs will be deleted without answer. (forum rule #6)
Extension for Firefox/Thunderbird: Master Password+    Back/Forward History Tweaks (restartless)    Cookies Manager+    Fit Images (restartless for Thunderbird)

Offline Sunny C.

  • Addicted member
  • ******
  • Posts: 1.805
  • I ♥ 4I
    • View Profile
Re: [1.7 / 1.7.1] PHP v5.1.x and PNG images error
« Reply #3 on: March 17, 2010, 12:43:55 AM »
Yes i have. But dont work.....
And is a fresh with little modifikation 4images installation
Png is an allowed file extensions!

Offline V@no

  • If you don't tell me what to do, I won't tell you where you should go :)
  • Global Moderator
  • 4images Guru
  • *****
  • Posts: 17.849
  • mmm PHP...
    • View Profile
    • 4images MODs Demo
Re: [1.7 / 1.7.1] PHP v5.1.x and PNG images error
« Reply #4 on: March 17, 2010, 01:44:23 AM »
and you have image/png  MIME type?
Your first three "must do" before you ask a question:
Please do not PM me asking for help unless you've been specifically asked to do so. Such PMs will be deleted without answer. (forum rule #6)
Extension for Firefox/Thunderbird: Master Password+    Back/Forward History Tweaks (restartless)    Cookies Manager+    Fit Images (restartless for Thunderbird)

Offline Sunny C.

  • Addicted member
  • ******
  • Posts: 1.805
  • I ♥ 4I
    • View Profile
Re: [1.7 / 1.7.1] PHP v5.1.x and PNG images error
« Reply #5 on: March 17, 2010, 01:58:11 AM »
Yes MIME
(image/png image/x-png)
Template:
Code: [Select]
<!-- Template file for PNG Files -->
<img src="{media_src}" border="1" alt="{image_name}"{width_height} /><br />
upload_definitions.php
$mime_type_match['png'] = array("image/png""image/x-png");
Full
<?php
/**************************************************************************
 *                                                                        *
 *    4images - A Web Based Image Gallery Management System               *
 *    ----------------------------------------------------------------    *
 *                                                                        *
 *             File: upload_definitions.php                               *
 *        Copyright: (C) 2002 Jan Sorgalla                                *
 *            Email: jan@4homepages.de                                    *
 *              Web: http://www.4homepages.de                             *
 *    Scriptversion: 1.7.6                                                *
 *                                                                        *
 *    Never released without support from: Nicky (http://www.nicky.net)   *
 *                                                                        *
 **************************************************************************
 *                                                                        *
 *    Dieses Script ist KEINE Freeware. Bitte lesen Sie die Lizenz-       *
 *    bedingungen (Lizenz.txt) für weitere Informationen.                 *
 *    ---------------------------------------------------------------     *
 *    This script is NOT freeware! Please read the Copyright Notice       *
 *    (Licence.txt) for further information.                              *
 *                                                                        *
 *************************************************************************/
if (!defined('ROOT_PATH')) {
  die(
"Security violation");
}
//AUTOMATICALLY GENERATED BY MIME.PHP PLUGIN

$mime_type_match['ai'] = array("application/postscript");
$mime_type_match['aif'] = array("audio/x-aiff");
$mime_type_match['aiff'] = array("audio/x-aiff");
$mime_type_match['au'] = array("audio/basic");
$mime_type_match['avi'] = array("video/x-msvideo""video/avi");
$mime_type_match['bmp'] = array("image/bmp""image/x-ms-bmp");
$mime_type_match['css'] = array("text/css");
$mime_type_match['csv'] = array("text/comma-separated-values");
$mime_type_match['doc'] = array("application/msword");
$mime_type_match['eps'] = array("application/postscript");
$mime_type_match['fla'] = array("application/octet-stream");
$mime_type_match['gif'] = array("image/gif");
$mime_type_match['gtar'] = array("application/x-gtar");
$mime_type_match['gz'] = array("application/gzip""application/x-gzip-compressed");
$mime_type_match['jpeg'] = array("image/jpg""image/jpeg""image/pjpeg");
$mime_type_match['jpg'] = array("image/jpg""image/jpeg""image/pjpeg");
$mime_type_match['js'] = array("text/javascript");
$mime_type_match['mid'] = array("audio/x-midi""audio/mid""audio/midi");
$mime_type_match['mov'] = array("video/quicktime");
$mime_type_match['mp3'] = array("audio/mpeg""audio/x-mpeg""audio/mp3""audio/mpg");
$mime_type_match['mpe'] = array("video/mpeg");
$mime_type_match['mpeg'] = array("video/mpeg");
$mime_type_match['mpg'] = array("video/mpeg");
$mime_type_match['pdf'] = array("application/pdf""application/x-pdf");
$mime_type_match['png'] = array("image/png""image/x-png");
$mime_type_match['ppt'] = array("application/vnd");
$mime_type_match['ps'] = array("application/postscript");
$mime_type_match['psd'] = array("application/octet-stream");
$mime_type_match['qt'] = array("video/quicktime");
$mime_type_match['ra'] = array("audio/x-pn-realaudio");
$mime_type_match['ram'] = array("audio/x-pn-realaudio");
$mime_type_match['rar'] = array("application/x-rar-compressed");
$mime_type_match['rm'] = array("audio/vnd.rn-realmedia""application/vnd.rn-realmedia""video/vnd.rn-realvideo""application/vnd");
$mime_type_match['rpm'] = array("audio/x-pn-realaudio-plugin");
$mime_type_match['rtf'] = array("text/plain""text/richtext""text/rtf");
$mime_type_match['rtx'] = array("text/plain""text/richtext""text/rtf");
$mime_type_match['sit'] = array("application/x-stuffit");
$mime_type_match['snd'] = array("audio/basic");
$mime_type_match['swf'] = array("application/x-shockwave-flash");
$mime_type_match['tar'] = array("application/x-tar");
$mime_type_match['tif'] = array("image/tiff""application/octet-stream");
$mime_type_match['tiff'] = array("image/tiff""application/octet-stream");
$mime_type_match['txt'] = array("text/plain""text/richtext""text/rtf""text/html");
$mime_type_match['wav'] = array("audio/x-wav");
$mime_type_match['xls'] = array("application/vnd""application/x-msexcel");
$mime_type_match['zip'] = array("application/zip""application/x-zip-compressed");
?>


Offline V@no

  • If you don't tell me what to do, I won't tell you where you should go :)
  • Global Moderator
  • 4images Guru
  • *****
  • Posts: 17.849
  • mmm PHP...
    • View Profile
    • 4images MODs Demo
Re: [1.7 / 1.7.1] PHP v5.1.x and PNG images error
« Reply #6 on: March 17, 2010, 02:27:02 AM »
Oh, that comes from thumbnail, which apparently doesn't use same list of MIME type as images...

Try this, in includes/upload.php find: (wrong!)
    $this->accepted_extensions['media'] = $config['allowed_mediatypes_array'];

Insert below:
    $this->accepted_extensions['thumb'] = $config['allowed_mediatypes_array'];

« Last Edit: March 18, 2010, 12:51:14 AM by V@no »
Your first three "must do" before you ask a question:
Please do not PM me asking for help unless you've been specifically asked to do so. Such PMs will be deleted without answer. (forum rule #6)
Extension for Firefox/Thunderbird: Master Password+    Back/Forward History Tweaks (restartless)    Cookies Manager+    Fit Images (restartless for Thunderbird)

Offline Sunny C.

  • Addicted member
  • ******
  • Posts: 1.805
  • I ♥ 4I
    • View Profile
Re: [1.7 / 1.7.1] PHP v5.1.x and PNG images error
« Reply #7 on: March 17, 2010, 08:08:03 AM »
Dont work, in Admin Panel comes:

Quote
Image file uploaded: bioshock2_details.png
Error while uploading the thumbnail image: bioshock2_thumbnail.png
bioshock2_details.png: The file has an invalid format (png, image / png)

Image file deleted
Data not written to the database

Please Help me!
« Last Edit: March 17, 2010, 09:10:55 PM by Sumale.nin »

Offline V@no

  • If you don't tell me what to do, I won't tell you where you should go :)
  • Global Moderator
  • 4images Guru
  • *****
  • Posts: 17.849
  • mmm PHP...
    • View Profile
    • 4images MODs Demo
Re: [1.7 / 1.7.1] PHP v5.1.x and PNG images error
« Reply #8 on: March 18, 2010, 12:50:02 AM »
My apology, my suggestion above was absolutely wrong...

In includes/upload.php find:
    foreach ($mime_type_match as $key => $val) {

Insert below:
      if (in_array($key$this->accepted_extensions['thumb'])) {
        if (
is_array($val)) {
          foreach (
$val as $key2 => $val2) {
            
$this->accepted_mime_types['thumb'][] = $val2;
          }
        }
        else {
          
$this->accepted_mime_types['thumb'][] = $val;
        }
      }
Your first three "must do" before you ask a question:
Please do not PM me asking for help unless you've been specifically asked to do so. Such PMs will be deleted without answer. (forum rule #6)
Extension for Firefox/Thunderbird: Master Password+    Back/Forward History Tweaks (restartless)    Cookies Manager+    Fit Images (restartless for Thunderbird)

Offline Sunny C.

  • Addicted member
  • ******
  • Posts: 1.805
  • I ♥ 4I
    • View Profile
Re: [1.7 / 1.7.1] PHP v5.1.x and PNG images error
« Reply #9 on: March 18, 2010, 10:58:10 AM »
WORKS VERY FINE!
Please write this fix in your first Post!

Thank you V@no, you are my Hero :P

LG