Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Transparency information is lost #65

Closed
anyguy opened this issue Jul 5, 2016 · 14 comments
Closed

Transparency information is lost #65

anyguy opened this issue Jul 5, 2016 · 14 comments

Comments

@anyguy
Copy link

anyguy commented Jul 5, 2016

Hello,

I'm using latest phpThumb from master and no matter what parameters I set, the trasparency information on the generated thumbnail is always lost.

<?php
require_once(dirname(__FILE__) . '/lib/phpthumb.class.php');

$phpThumb = new phpThumb();
$phpThumb->setParameter('config_disable_debug', false);
$phpThumb->setParameter('config_allow_src_above_docroot', true);
$phpThumb->setSourceFilename(dirname(__FILE__) . '/test-alpha.png');

$phpThumb->setParameter('w', 320);
$phpThumb->setParameter('h', 320);

$phpThumb->setParameter('zc', 'C');
$phpThumb->setParameter('f', 'png');

$phpThumb->GenerateThumbnail();
$phpThumb->RenderToFile(dirname(__FILE__) . "/result.png");

The transparent png is this one:
test-alpha

and the result.png is this (of course it looks identical because the background of the page here is also white!)
result

Is this a known problem? Do you know of any workaround to preserve the transparency in the generated thumbnail?

Thanks!

@JamesHeinrich
Copy link
Owner

It is not a known problem. I just tried your sample image, both passed through at 320x320 and resized to 200x200 and transparency was preserved as expected.
Admitted my quick test was run through phpThumb.php?src=in.png&w=320&h=320&f=png rather than the object style of your example, but it shouldn't make any difference.

Perhaps if you add

$phpThumb->f = 'text';
$phpThumb->phpThumbDebug();

to the end of your code sample you can get the debug log. Search through there for references to "alpha" (e.g. "AlphaChannelFlatten"). Also please confirm whether the image is being processed through GD or ImageMagick in your installation, and if applicable what version of ImageMagick is installed.

If the debug messages don't point you to the right solution immediately, please copy-paste all the lines references "alpha" or "imagemagick" here.

@lyquix-owner
Copy link

I am having the same problem, transparency in PNGs is lost in all instances.

Environment:

Ubuntu 14.04
PHP 5.5.9

The fail is visible even in the phpthumb demo page:
http://www.lyquix.com/tmp/phpThumb/demo/phpThumb.demo.demo.php#x12

Here is the debug log for the test phpThumb.php?src=images%2Falpha.png&f=png

phpThumb() v1.7.14-201607160645
http://phpthumb.sourceforge.net

phpThumb() version          = 1.7.14-201607160645
phpversion()                = 5.5.9-1ubuntu4.17
PHP_OS                      = Linux
$_SERVER[SERVER_SOFTWARE]   = Apache/2.4.7 (Ubuntu)
__FILE__                    = /srv/www/lyquix.com/public_html/tmp/phpThumb/phpthumb.class.php
realpath(.)                 = /srv/www/lyquix.com/public_html/tmp/phpThumb
$_SERVER[PHP_SELF]          = /tmp/phpThumb/phpThumb.php
$_SERVER[HOST_NAME]         = 
$_SERVER[HTTP_REFERER]      = https://www.lyquix.com/tmp/phpThumb/demo/phpThumb.demo.demo.php
$_SERVER[QUERY_STRING]      = src=images%2Falpha.png&f=png&hash=0632699ce4250181f26d6a38da99095c
$_SERVER[PATH_INFO]         = 
$_SERVER[DOCUMENT_ROOT]     = /srv/www/lyquix.com/public_html/
getenv(DOCUMENT_ROOT)       = /srv/www/lyquix.com/public_html/

get_magic_quotes_gpc()         = FALSE
get_magic_quotes_runtime()     = FALSE
error_reporting()              = integer     32767
ini_get(error_reporting)       = string(1)   "0"
ini_get(display_errors)        = string(1)   "1"
ini_get(allow_url_fopen)       = string(1)   "1"
ini_get(disable_functions)     = string(320) "pcntl_alarm,pcntl_fork,pcntl_waitpid,pcntl_wait,pcntl_wifexited,pcntl_wifstopped,pcntl_wifsignaled,pcntl_wexitstatus,pcntl_wtermsig,pcntl_wstopsig,pcntl_signal,pcntl_signal_dispatch,pcntl_get_last_error,pcntl_strerror,pcntl_sigprocmask,pcntl_sigwaitinfo,pcntl_sigtimedwait,pcntl_exec,pcntl_getpriority,pcntl_setpriority,"
get_cfg_var(disable_functions) = string(320) "pcntl_alarm,pcntl_fork,pcntl_waitpid,pcntl_wait,pcntl_wifexited,pcntl_wifstopped,pcntl_wifsignaled,pcntl_wexitstatus,pcntl_wtermsig,pcntl_wstopsig,pcntl_signal,pcntl_signal_dispatch,pcntl_get_last_error,pcntl_strerror,pcntl_sigprocmask,pcntl_sigwaitinfo,pcntl_sigtimedwait,pcntl_exec,pcntl_getpriority,pcntl_setpriority,"
ini_get(safe_mode)             = FALSE
ini_get(open_basedir)          = string(0)   ""
ini_get(max_execution_time)    = string(2)   "60"
ini_get(memory_limit)          = string(4)   "128M"
get_cfg_var(memory_limit)      = string(4)   "128M"
memory_get_usage()             = integer     2334608

$this->config_prefer_imagemagick            = TRUE
$this->config_imagemagick_path              = NULL
$this->ImageMagickWhichConvert()            = /usr/bin/convert
[actual ImageMagick path used]              = string(16)  "/usr/bin/convert"
file_exists([actual ImageMagick path used]) = TRUE
ImageMagickVersion(false)                   = 6.7.7-10 2016-06-01 Q16
ImageMagickVersion(true)                    = Version: ImageMagick 6.7.7-10 2016-06-01 Q16 http://www.imagemagick.org
Copyright: Copyright (C) 1999-2012 ImageMagick Studio LLC
Features: OpenMP

$this->config_cache_directory               = string(51)  "/srv/www/lyquix.com/public_html/tmp/phpThumb/cache/"
$this->config_cache_directory_depth         = integer     2
$this->config_cache_disable_warning         = FALSE
$this->config_cache_maxage                  = integer     2592000
$this->config_cache_maxsize                 = integer     10485760
$this->config_cache_maxfiles                = integer     200
$this->config_cache_force_passthru          = TRUE
$this->cache_filename                       = string(173) "/srv/www/lyquix.com/public_html/tmp/phpThumb/cache//c/c3/phpThumb_cache_lyquix.com__srcc3790a0952fb46c12c0bc814b289792c_par80d8993b181666aca11d7be02b12fea7_dat1469725898.png"
is_readable($this->config_cache_directory)  = TRUE
is_writable($this->config_cache_directory)  = TRUE
is_readable($this->cache_filename)          = TRUE
is_writable($this->cache_filename)          = TRUE

$this->config_document_root                  = string(45)  "/srv/www/lyquix.com/public_html/tmp/phpThumb/"
$this->config_temp_directory                 = string(50)  "/srv/www/lyquix.com/public_html/tmp/phpThumb/cache"
$this->config_output_format                  = string(4)   "jpeg"
$this->config_output_maxwidth                = integer     0
$this->config_output_maxheight               = integer     0
$this->config_error_message_image_default    = string(0)   ""
$this->config_error_bgcolor                  = string(6)   "CCCCFF"
$this->config_error_textcolor                = string(6)   "FF0000"
$this->config_error_fontsize                 = integer     1
$this->config_error_die_on_error             = TRUE
$this->config_error_silent_die_on_error      = FALSE
$this->config_error_die_on_source_failure    = TRUE
$this->config_nohotlink_enabled              = TRUE
$this->config_nohotlink_valid_domains        = array(1) {   [0]=>   string(14) "www.lyquix.com" } 
$this->config_nohotlink_erase_image          = TRUE
$this->config_nohotlink_text_message         = string(38)  "Off-server thumbnailing is not allowed"
$this->config_nooffsitelink_enabled          = TRUE
$this->config_nooffsitelink_valid_domains    = array(1) {   [0]=>   string(14) "www.lyquix.com" } 
$this->config_nooffsitelink_require_refer    = FALSE
$this->config_nooffsitelink_erase_image      = FALSE
$this->config_nooffsitelink_text_message     = string(31)  "Image taken from www.lyquix.com"
$this->config_high_security_enabled          = FALSE
$this->config_allow_src_above_docroot        = FALSE
$this->config_allow_src_above_phpthumb       = TRUE
$this->config_max_source_pixels              = float       22369621
$this->config_use_exif_thumbnail_for_speed   = FALSE
$this->config_border_hexcolor                = string(6)   "000000"
$this->config_background_hexcolor            = string(6)   "FFFFFF"
$this->config_ttf_directory                  = string(50)  "/srv/www/lyquix.com/public_html/tmp/phpThumb/fonts"
$this->config_disable_pathinfo_parsing       = TRUE
$this->config_disable_imagecopyresampled     = FALSE

$this->phpThumbDebug               = integer     9
$this->thumbnailQuality            = integer     75
$this->thumbnailFormat             = string(3)   "png"
$this->gdimg_output                = NULL
$this->gdimg_source                = resource
$this->sourceFilename              = string(61)  "/srv/www/lyquix.com/public_html/tmp/phpThumb/images/alpha.png"
$this->source_width                = integer     120
$this->source_height               = integer     90
$this->thumbnailCropX              = NULL
$this->thumbnailCropY              = NULL
$this->thumbnailCropW              = NULL
$this->thumbnailCropH              = NULL
$this->exif_thumbnail_width        = NULL
$this->exif_thumbnail_height       = NULL
$this->exif_thumbnail_type         = NULL
$this->thumbnail_width             = NULL
$this->thumbnail_height            = NULL
$this->thumbnail_image_width       = NULL
$this->thumbnail_image_height      = NULL
strlen($this->rawImageData)        = 0
strlen($this->exif_thumbnail_data) = 0

$this->src  = string(61)  "/srv/www/lyquix.com/public_html/tmp/phpThumb/images/alpha.png"
$this->new  = NULL
$this->w    = string(0)   ""
$this->h    = string(0)   ""
$this->f    = string(3)   "png"
$this->q    = integer     75
$this->sx   = NULL
$this->sy   = NULL
$this->sw   = NULL
$this->sh   = NULL
$this->far  = NULL
$this->bg   = NULL
$this->bc   = NULL
$this->file = NULL
$this->goto = NULL
$this->err  = NULL
$this->xto  = NULL
$this->ra   = NULL
$this->ar   = NULL
$this->aoe  = NULL
$this->iar  = NULL
$this->maxb = NULL

builtin_function_exists(exif_thumbnail)          = TRUE
builtin_function_exists(gd_info)                 = TRUE
builtin_function_exists(image_type_to_mime_type) = TRUE
builtin_function_exists(getimagesize)            = TRUE
builtin_function_exists(imagecopyresampled)      = TRUE
builtin_function_exists(imagecopyresized)        = TRUE
builtin_function_exists(imagecreate)             = TRUE
builtin_function_exists(imagecreatefromstring)   = TRUE
builtin_function_exists(imagecreatetruecolor)    = TRUE
builtin_function_exists(imageistruecolor)        = TRUE
builtin_function_exists(imagerotate)             = TRUE
builtin_function_exists(imagetypes)              = TRUE
builtin_function_exists(version_compare)         = TRUE
builtin_function_exists(imagecreatefromgif)      = TRUE
builtin_function_exists(imagecreatefromjpeg)     = TRUE
builtin_function_exists(imagecreatefrompng)      = TRUE
builtin_function_exists(imagecreatefromwbmp)     = TRUE
builtin_function_exists(imagecreatefromxbm)      = TRUE
builtin_function_exists(imagecreatefromxpm)      = TRUE
builtin_function_exists(imagecreatefromstring)   = TRUE
builtin_function_exists(imagecreatefromgd)       = TRUE
builtin_function_exists(imagecreatefromgd2)      = TRUE
builtin_function_exists(imagecreatefromgd2part)  = TRUE
builtin_function_exists(imagejpeg)               = TRUE
builtin_function_exists(imagegif)                = TRUE
builtin_function_exists(imagepng)                = TRUE
builtin_function_exists(imagewbmp)               = TRUE

gd_info.GD Version                         = string(9)   "2.1.1-dev"
gd_info.FreeType Support                   = TRUE
gd_info.FreeType Linkage                   = string(13)  "with freetype"
gd_info.T1Lib Support                      = FALSE
gd_info.GIF Read Support                   = TRUE
gd_info.GIF Create Support                 = TRUE
gd_info.JPEG Support                       = TRUE
gd_info.PNG Support                        = TRUE
gd_info.WBMP Support                       = TRUE
gd_info.XPM Support                        = TRUE
gd_info.XBM Support                        = TRUE
gd_info.JIS-mapped Japanese Font Support   = FALSE

exif_info.EXIF Support               = string(7)   "enabled"
exif_info.EXIF Version               = string(8)   "1.4 $Id$"
exif_info.Supported EXIF Version     = string(4)   "0220"
exif_info.Supported filetypes        = string(9)   "JPEG,TIFF"

ApacheLookupURIarray() -- FAILED

$_GET[src]                           = string(16)  "images/alpha.png"
$_GET[f]                             = string(3)   "png"
$_GET[hash]                          = string(32)  "0632699ce4250181f26d6a38da99095c"
$_GET[phpThumbDebug]                 = integer     9

$this->debugmessages:
  * phpThumb() v1.7.14-201607160645 in file "phpthumb.class.php" on line 227
  * setParameter(config_document_root, string(45)  "/srv/www/lyquix.com/public_html/tmp/phpThumb/") in file "phpThumb.php" on line 150
  * setParameter(config_disable_debug, FALSE) in file "phpThumb.php" on line 150
  * setParameter(config_high_security_enabled, FALSE) in file "phpThumb.php" on line 150
  * setParameter(config_high_security_url_separator, string(1)   "&") in file "phpThumb.php" on line 150
  * setParameter(config_allow_src_above_docroot, FALSE) in file "phpThumb.php" on line 150
  * setParameter(config_allow_src_above_phpthumb, TRUE) in file "phpThumb.php" on line 150
  * setParameter(config_auto_allow_symlinks, TRUE) in file "phpThumb.php" on line 150
  * setParameter(config_additional_allowed_dirs, array(0) { } ) in file "phpThumb.php" on line 150
  * setParameter(config_cache_directory, string(51)  "/srv/www/lyquix.com/public_html/tmp/phpThumb/cache/") in file "phpThumb.php" on line 150
  * setParameter(config_cache_disable_warning, FALSE) in file "phpThumb.php" on line 150
  * setParameter(config_cache_directory_depth, integer     2) in file "phpThumb.php" on line 150
  * setParameter(config_cache_maxage, integer     2592000) in file "phpThumb.php" on line 150
  * setParameter(config_cache_maxsize, integer     10485760) in file "phpThumb.php" on line 150
  * setParameter(config_cache_maxfiles, integer     200) in file "phpThumb.php" on line 150
  * setParameter(config_cache_source_enabled, FALSE) in file "phpThumb.php" on line 150
  * setParameter(config_cache_source_directory, string(58)  "/srv/www/lyquix.com/public_html/tmp/phpThumb/cache/source/") in file "phpThumb.php" on line 150
  * setParameter(config_cache_source_filemtime_ignore_local, FALSE) in file "phpThumb.php" on line 150
  * setParameter(config_cache_source_filemtime_ignore_remote, TRUE) in file "phpThumb.php" on line 150
  * setParameter(config_cache_default_only_suffix, string(0)   "") in file "phpThumb.php" on line 150
  * setParameter(config_cache_prefix, string(26)  "phpThumb_cache_lyquix.com_") in file "phpThumb.php" on line 150
  * setParameter(config_cache_force_passthru, TRUE) in file "phpThumb.php" on line 150
  * setParameter(config_temp_directory, string(51)  "/srv/www/lyquix.com/public_html/tmp/phpThumb/cache/") in file "phpThumb.php" on line 150
  * setParameter(config_prefer_imagemagick, TRUE) in file "phpThumb.php" on line 150
  * setParameter(config_imagemagick_use_thumbnail, TRUE) in file "phpThumb.php" on line 150
  * setParameter(config_imagemagick_path, NULL) in file "phpThumb.php" on line 150
  * setParameter(config_max_source_pixels, float       22369621) in file "phpThumb.php" on line 150
  * setParameter(config_output_format, string(4)   "jpeg") in file "phpThumb.php" on line 150
  * setParameter(config_output_maxwidth, integer     0) in file "phpThumb.php" on line 150
  * setParameter(config_output_maxheight, integer     0) in file "phpThumb.php" on line 150
  * setParameter(config_output_interlace, TRUE) in file "phpThumb.php" on line 150
  * setParameter(config_error_image_width, integer     400) in file "phpThumb.php" on line 150
  * setParameter(config_error_image_height, integer     100) in file "phpThumb.php" on line 150
  * setParameter(config_error_message_image_default, string(0)   "") in file "phpThumb.php" on line 150
  * setParameter(config_error_bgcolor, string(6)   "CCCCFF") in file "phpThumb.php" on line 150
  * setParameter(config_error_textcolor, string(6)   "FF0000") in file "phpThumb.php" on line 150
  * setParameter(config_error_fontsize, integer     1) in file "phpThumb.php" on line 150
  * setParameter(config_error_die_on_error, TRUE) in file "phpThumb.php" on line 150
  * setParameter(config_error_silent_die_on_error, FALSE) in file "phpThumb.php" on line 150
  * setParameter(config_error_die_on_source_failure, TRUE) in file "phpThumb.php" on line 150
  * setParameter(config_nohotlink_enabled, TRUE) in file "phpThumb.php" on line 150
  * setParameter(config_nohotlink_valid_domains, array(1) {   [0]=>   string(14) "www.lyquix.com" } ) in file "phpThumb.php" on line 150
  * setParameter(config_nohotlink_erase_image, TRUE) in file "phpThumb.php" on line 150
  * setParameter(config_nohotlink_text_message, string(38)  "Off-server thumbnailing is not allowed") in file "phpThumb.php" on line 150
  * setParameter(config_nooffsitelink_enabled, TRUE) in file "phpThumb.php" on line 150
  * setParameter(config_nooffsitelink_valid_domains, array(1) {   [0]=>   string(14) "www.lyquix.com" } ) in file "phpThumb.php" on line 150
  * setParameter(config_nooffsitelink_require_refer, FALSE) in file "phpThumb.php" on line 150
  * setParameter(config_nooffsitelink_erase_image, FALSE) in file "phpThumb.php" on line 150
  * setParameter(config_nooffsitelink_watermark_src, string(26)  "/demo/images/watermark.png") in file "phpThumb.php" on line 150
  * setParameter(config_nooffsitelink_text_message, string(31)  "Image taken from www.lyquix.com") in file "phpThumb.php" on line 150
  * setParameter(config_border_hexcolor, string(6)   "000000") in file "phpThumb.php" on line 150
  * setParameter(config_background_hexcolor, string(6)   "FFFFFF") in file "phpThumb.php" on line 150
  * setParameter(config_ttf_directory, string(50)  "/srv/www/lyquix.com/public_html/tmp/phpThumb/fonts") in file "phpThumb.php" on line 150
  * setParameter(config_http_user_agent, string(110) "Mozilla/5.0 (Windows NT 10.0; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/51.0.2704.103 Safari/537.36") in file "phpThumb.php" on line 150
  * setParameter(config_disable_pathinfo_parsing, TRUE) in file "phpThumb.php" on line 150
  * setParameter(config_disable_imagecopyresampled, FALSE) in file "phpThumb.php" on line 150
  * setParameter(config_disable_onlycreateable_passthru, TRUE) in file "phpThumb.php" on line 150
  * setParameter(config_disable_realpath, FALSE) in file "phpThumb.php" on line 150
  * setParameter(config_http_fopen_timeout, integer     10) in file "phpThumb.php" on line 150
  * setParameter(config_http_follow_redirect, TRUE) in file "phpThumb.php" on line 150
  * setParameter(config_allow_local_http_src, FALSE) in file "phpThumb.php" on line 150
  * setParameter(config_use_exif_thumbnail_for_speed, FALSE) in file "phpThumb.php" on line 150
  * setParameter(src, string(16)  "images/alpha.png") in file "phpThumb.php" on line 383
  * resolvePath: /srv/www/lyquix.com/public_html/tmp/phpThumb/images/alpha.png (allowed_dirs: Array
(
)
) in file "phpthumb.class.php" on line 1137
  * resolvePath: iteration, path=/srv/www/lyquix.com/public_html/tmp/phpThumb/images/alpha.png, base path = /srv/www/lyquix.com/public_html/tmp/phpThumb in file "phpthumb.class.php" on line 1156
  * open_basedir: "" in file "phpthumb.class.php" on line 1123
  * resolvePath: stop at component 9 in file "phpthumb.class.php" on line 1172
  * resolvePath: stop at path=/srv/www/lyquix.com/public_html/tmp/phpThumb/images/alpha.png in file "phpthumb.class.php" on line 1175
  * resolvePath: path parsed, over in file "phpthumb.class.php" on line 1181
  * setSourceFilename(/srv/www/lyquix.com/public_html/tmp/phpThumb/images/alpha.png) set $this->sourceFilename to "/srv/www/lyquix.com/public_html/tmp/phpThumb/images/alpha.png" in file "phpthumb.class.php" on line 292
  * setParameter(f, string(3)   "png") in file "phpThumb.php" on line 383
  * setParameter(hash, string(32)  "0632699ce4250181f26d6a38da99095c") in file "phpThumb.php" on line 383
  * setParameter(phpThumbDebug, integer     9) in file "phpThumb.php" on line 383
  * $CanPassThroughDirectly=false because $_GET[f;hash] are set in file "phpThumb.php" on line 466
  * $CanPassThroughDirectly="0" && $phpThumb->src="/srv/www/lyquix.com/public_html/tmp/phpThumb/images/alpha.png" in file "phpThumb.php" on line 477
  * Addding ImageMagick formats to $AvailableImageOutputFormats (text;ico;bmp;wbmp;gif;png;jpeg) in file "phpthumb.class.php" on line 960
  * $AvailableImageOutputFormats = array(text;ico;bmp;wbmp;gif;png;jpeg) in file "phpthumb.class.php" on line 966
  * $this->thumbnailFormat set to $this->config_output_format "jpeg" in file "phpthumb.class.php" on line 977
  * $this->thumbnailFormat set to $this->f "png" in file "phpthumb.class.php" on line 984
  * $this->thumbnailQuality set to "75" in file "phpthumb.class.php" on line 994
  * SetCacheFilename() _src set from md5($this->sourceFilename) "/srv/www/lyquix.com/public_html/tmp/phpThumb/images/alpha.png" = "c3790a0952fb46c12c0bc814b289792c" in file "phpthumb.class.php" on line 3511
  * SetCacheFilename() _par set from md5(_dpi150) in file "phpthumb.class.php" on line 3544
  * Would have used cached file, but skipping due to phpThumbDebug in file "phpThumb.php" on line 61
  * * Would have sent headers (1): Last-Modified: Thu, 28 Jul 2016 17:15:11 GMT in file "phpThumb.php" on line 62
  * * Would have sent headers (2): Content-Type: image/png in file "phpThumb.php" on line 64
  * * Would have sent headers (3): Location: /cache//c/c3/phpThumb_cache_lyquix.com__srcc3790a0952fb46c12c0bc814b289792c_par80d8993b181666aca11d7be02b12fea7_dat1469725898.png in file "phpThumb.php" on line 67
  * resolvePath: /srv/www/lyquix.com/public_html/tmp/phpThumb/images/alpha.png (allowed_dirs: Array
(
)
) in file "phpthumb.class.php" on line 1137
  * resolvePath: iteration, path=/srv/www/lyquix.com/public_html/tmp/phpThumb/images/alpha.png, base path = /srv/www/lyquix.com/public_html/tmp/phpThumb in file "phpthumb.class.php" on line 1156
  * resolvePath: stop at component 9 in file "phpthumb.class.php" on line 1172
  * resolvePath: stop at path=/srv/www/lyquix.com/public_html/tmp/phpThumb/images/alpha.png in file "phpthumb.class.php" on line 1175
  * resolvePath: path parsed, over in file "phpthumb.class.php" on line 1181
  * $this->sourceFilename set to "/srv/www/lyquix.com/public_html/tmp/phpThumb/images/alpha.png" in file "phpthumb.class.php" on line 891
  * $this->cache_filename already set, skipping SetCacheFilename() in file "phpthumb.class.php" on line 3467
  * starting ExtractEXIFgetImageSize() in file "phpthumb.class.php" on line 3305
  * getimagesize(/srv/www/lyquix.com/public_html/tmp/phpThumb/images/alpha.png) says image is 120x90 in file "phpthumb.class.php" on line 3315
  * $this->useRawIMoutput=true after checking $UnAllowedParameters in file "phpthumb.class.php" on line 1588
  * phpThumb_tempnam() returning "/srv/www/lyquix.com/public_html/tmp/phpThumb/cache/pThumbWPr7un" in file "phpthumb.class.php" on line 4345
  * ImageMagickSwitchAvailable(thumbnail) = 1 in file "phpthumb.class.php" on line 1525
  * ImageMagickSwitchAvailable(density) = 1 in file "phpthumb.class.php" on line 1525
  * getimagesize(/srv/www/lyquix.com/public_html/tmp/phpThumb/images/alpha.png) SUCCEEDED: Array
(
    [0] => 120
    [1] => 90
    [2] => 3
    [3] => width="120" height="90"
    [bits] => 8
    [mime] => image/png
)
 in file "phpthumb.class.php" on line 1681
  * getimagesize(/srv/www/lyquix.com/public_html/tmp/phpThumb/images/alpha.png) returned [w=120;h=90;f=3] in file "phpthumb.class.php" on line 1686
  * source dimensions set to 120x90 in file "phpthumb.class.php" on line 1689
  * SetOrientationDependantWidthHeight() starting with "120"x"90" in file "phpthumb.class.php" on line 3284
  * SetOrientationDependantWidthHeight() setting w="0", h="0" in file "phpthumb.class.php" on line 3300
  * Remaining $this->fltr after ImageMagick: (array(0) { } ) in file "phpthumb.class.php" on line 2213
  * ImageMagick called as (convert -flatten -density '150' '/srv/www/lyquix.com/public_html/tmp/phpThumb/images/alpha.png[0]' png:'/srv/www/lyquix.com/public_html/tmp/phpThumb/cache/pThumbWPr7un' 2>&1) in file "phpthumb.class.php" on line 2232
  * getimagesize(/srv/www/lyquix.com/public_html/tmp/phpThumb/cache/pThumbWPr7un) returned [w=120;h=90;f=3] in file "phpthumb.class.php" on line 2249
  * ImageMagickThumbnailToGD::imagecreatefrompng() succeeded, $this->gdimg_source is now (120x90) in file "phpthumb.class.php" on line 2255
  * ImageMagickThumbnailToGD() returning $this->IMresizedData (597 bytes) in file "phpthumb.class.php" on line 2256
  * deleting "/srv/www/lyquix.com/public_html/tmp/phpThumb/cache/pThumbWPr7un" in file "phpthumb.class.php" on line 2262
  * Skipping rest of GenerateThumbnail() because ($this->useRawIMoutput == true) in file "phpthumb.class.php" on line 367
  * CleanUpCacheDirectory() set to purge (30.0 days; 10.00 MB; 200 files) in file "phpthumb.class.php" on line 709
  * CleanUpCacheDirectory() skipped because "/srv/www/lyquix.com/public_html/tmp/phpThumb/cache//phpThumbCacheStats.txt" is recently modified in file "phpthumb.class.php" on line 719
  * RenderOutput copying $this->IMresizedData (597 bytes) to $this->outputImage in file "phpthumb.class.php" on line 454
  * RenderToFile(/srv/www/lyquix.com/public_html/tmp/phpThumb/cache//c/c3/phpThumb_cache_lyquix.com__srcc3790a0952fb46c12c0bc814b289792c_par80d8993b181666aca11d7be02b12fea7_dat1469725898.png) succeeded in file "phpthumb.class.php" on line 597
  * Would have used cached file, but skipping due to phpThumbDebug in file "phpThumb.php" on line 61
  * * Would have sent headers (1): Last-Modified: Thu, 28 Jul 2016 17:15:11 GMT in file "phpThumb.php" on line 62
  * * Would have sent headers (2): Content-Type: image/png in file "phpThumb.php" on line 64
  * * Would have sent headers (3): Location: /cache//c/c3/phpThumb_cache_lyquix.com__srcc3790a0952fb46c12c0bc814b289792c_par80d8993b181666aca11d7be02b12fea7_dat1469725898.png in file "phpThumb.php" on line 67

$this->debugtiming:
  * 1469726221.627756 : phpThumb() constructor in file "phpthumb.class.php" on line 226
  * 1469726221.616343 : phpThumb.php start in file "phpThumb.php" on line 117
  * 1469726221.629353 : phpThumbDebug[0] in file "phpThumb.php" on line 209
  * 1469726221.629398 : phpThumbDebug[1] in file "phpThumb.php" on line 266
  * 1469726221.629439 : phpThumbDebug[2] in file "phpThumb.php" on line 368
  * 1469726221.629667 : phpThumbDebug[3] in file "phpThumb.php" on line 404
  * 1469726221.629709 : phpThumbDebug[4] in file "phpThumb.php" on line 471
  * 1469726221.629728 : phpThumbDebug[5] in file "phpThumb.php" on line 557
  * 1469726221.629949 : skipped using cached image in file "phpThumb.php" on line 60
  * 1469726221.630046 : phpThumbDebug[6] in file "phpThumb.php" on line 573
  * 1469726221.630069 : phpThumbDebug[7] in file "phpThumb.php" on line 638
  * 1469726221.670319 : phpThumbDebug[8] in file "phpThumb.php" on line 648
  * 1469726221.670766 : skipped using cached image in file "phpThumb.php" on line 60
  * 1469726221.670930 : phpThumbDebug[9] in file "phpThumb.php" on line 681
  * Total processing time: 0.054587

JamesHeinrich added a commit that referenced this issue Jul 28, 2016
@JamesHeinrich
Copy link
Owner

Does e9a8cea (remove -flatten from the call to ImageMagick) fix your problem?
If so I'm not sure why $this->dpi is being set, perhaps I'll need to take a closer look if that's the case.

@ggppdk
Copy link
Contributor

ggppdk commented Jul 28, 2016

Do you have ImageMagick 6.7.7-10 ?

Release date of it was ?: 2012-06-29

Latest:
https://sourceforge.net/projects/imagemagick/files/

Older:
https://sourceforge.net/projects/imagemagick/files/old-sources/

Here you can see 6.7.7-10 has release date: 2012-06-29
https://sourceforge.net/projects/imagemagick/files/old-sources/6.x/6.7/

I think ImageMagick had a bug with alpha transparency that was fixed after 6.8.nn ?

http://superuser.com/questions/636008/convert-bmp-to-png-while-preserving-alpha-channel

The above link, speaks about bmp to png, but does not say if bug applies to png to png too

I do not know if removing -flatten is enough, and if removing it will create problems with other cases

  • can you try updating ImageMagick to a later version ?

@lyquix-owner
Copy link

In both my local development environment, and the public server I have:

imagick module enabled
imagick module version 3.1.2
imagick classes Imagick, ImagickDraw, ImagickPixel, ImagickPixelIterator
ImageMagick version ImageMagick 6.7.7-10 2016-06-01 Q16 http://www.imagemagick.org
ImageMagick copyright Copyright (C) 1999-2012 ImageMagick Studio LLC
ImageMagick release date 2016-06-01
ImageMagick number of supported formats: 213

@ggppdk
Copy link
Contributor

ggppdk commented Jul 29, 2016

That maybe release of the binary package

But the source code version was first released on 2012-06-29

e.g. see at the top of the changelog of the particular release

2012-06-28 6.7.7-10 Cristy

  • New version 6.7.7-10, SVN revision 8534.

imagemagick_releases

@lyquix-owner
Copy link

@ggppdk I don't know how to check that, I found the directory /usr/include/php5/ext/imagick containing 3 .h files.

@ggppdk the problem was fixed by rolling back to the phpthumb version used in FC 3.0.14-rc

@JamesHeinrich I will test using the library including that commit and let you know if that fixes the problem

@lyquix-owner
Copy link

@JamesHeinrich the latest commit fixes the problem. Thank you!

@JamesHeinrich
Copy link
Owner

JamesHeinrich commented Jul 29, 2016

Unfortunately my "fix" may also break some things, like PDF as source image, so I don't really want to leave it in place if it's a buggy ImageMagick causing the problem. Any chance you're able to upgrade ImageMagick to v6.8.9+ and test with -flatten uncommented back in (phpthumb.class.php line 1674)?

@ggppdk
Copy link
Contributor

ggppdk commented Jul 29, 2016

Can "-flatten" be removed only if input source is "png" ?

or even this will cause problems:
with other imageMagick versions and png source ?

@JamesHeinrich
Copy link
Owner

-flatten is (sometimes) needed for vector input format (PDF, WMF, etc), and also when using an animated GIF source and outputting to a non-alpha-capable format (e.g. JPEG).

@ggppdk
Copy link
Contributor

ggppdk commented Oct 26, 2016

-flatten is (sometimes) needed for vector input format (PDF, WMF, etc), and also when using an animated GIF source and outputting to a non-alpha-capable format (e.g. JPEG).

Right, but is it possible to remove it only for PNG input format ?

There are quite a few servers that have older ImageMagick versions (or GD? versions) that do not work with it, and loose the PNG transparency

I have tested moving the getimagesize further up (in order to get the image type earlier)

ob_start();
$getimagesize = getimagesize($this->sourceFilename);
$GetImageSizeError = ob_get_contents();
ob_end_clean();

and the exclude PNG from using -flatten

// for vector source formats only (WMF, PDF, etc)
if (!is_array($getimagesize) || $getimagesize[2] != IMAGETYPE_PNG)
{
    $commandline .= ' -flatten';
}

It seems to be working properly

@JamesHeinrich
Copy link
Owner

Let me know if there are any problems with 6a9d994

@ggppdk
Copy link
Contributor

ggppdk commented Oct 27, 2016

Thanks this fixed the issue,

tested in 2 different servers

1 server that had the issue with PNG transparency,
and 1 server that did not have the issue

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants