forum.coppermine-gallery.net

Support => cpg1.5.x Support => cpg1.5 upload => Topic started by: flapane on June 08, 2012, 12:34:55 pm

Title: Problem resizing or creating thumbnails
Post by: flapane on June 08, 2012, 12:34:55 pm
Quote
Critical error
Unable to create thumbnail or reduced size image.

File: /[.foo..]/gallery/db_input.php - Line: 699

It has worked well until some weeks ago, and I haven't uploaded photos, changed cpg core files or any settings from then on.
I tried with different jpg files bigger and smaller than 1285px (my max size for original pic).

I've read the troubleshooter and created a test account.
username: cpg_test
pwd: problem
Title: Re: Problem resizing or creating thumbnails
Post by: Αndré on June 08, 2012, 12:41:41 pm
Please post a link to the affected gallery.
Title: Re: Problem resizing or creating thumbnails
Post by: flapane on June 08, 2012, 12:42:47 pm
The one in the signature (as per forum rule).
Title: Re: Problem resizing or creating thumbnails
Post by: Αndré on June 08, 2012, 02:03:03 pm
Link to gallery: http://www.flapane.com/gallery/

The script dies at line 699, which means that add_picture returned something different than "true". I guess you already checked the directory permissions? If so, we'd need to debug the function add_picture by commenting out some code parts to find the issue (in include/picmgmt.inc.php).
Title: Re: Problem resizing or creating thumbnails
Post by: flapane on June 08, 2012, 02:54:37 pm
Thanks. Sure, I checked folder permissions while reading the troubleshooter, and found nothing weird.
Title: Re: Problem resizing or creating thumbnails
Post by: CharlieD on June 09, 2012, 02:43:38 am
I cannot upload photos. I followed the instructions very carefully and they will not upload. this is the message I receive:

critical error
unable to create thumbnail or reduced size image
File: /home/academi/public_html/CFC/db_input.php - Line: 666


http://www.academicangler.com/CFC/db_input.php
Title: Re: Problem resizing or creating thumbnails
Post by: flapane on June 09, 2012, 09:21:59 am
Different code line. You'd better open a new thread.
Title: Re: Problem resizing or creating thumbnails
Post by: Stevellewor on June 12, 2012, 10:19:59 am
I have exactly the same issue as you flapane, if you find a solution I would be pleased to know what it is. If I have any luck sorting it out will let you know.
Title: Re: Problem resizing or creating thumbnails
Post by: flapane on June 12, 2012, 10:42:54 am
I'm waiting for Andrč to suggest me which lines to comment for debugging purposes.
Title: Re: Problem resizing or creating thumbnails
Post by: Αndré on June 14, 2012, 11:42:47 am
Have a look at include/picmgmt.inc.php. Within the
Code: [Select]
} elseif (is_image($filename)) {block you'll find a couple of if-blocks. Try to comment them out one by one to find out which one doesn't work as expected. It's hard to explain how to find the cause, it's probably easier to give me FTP access to your gallery. But I'm currently quite busy and don't know when I'll find time to work on that issue.
Title: Re: Problem resizing or creating thumbnails
Post by: flapane on June 14, 2012, 12:27:51 pm
Tried with no luck (the if blocks end at line 101).
I've also set up an account for you. Check PM.
Title: Re: Problem resizing or creating thumbnails
Post by: flapane on June 14, 2012, 12:29:10 pm
err... no PM folders for admins.
Title: Re: Problem resizing or creating thumbnails
Post by: Αndré on June 14, 2012, 02:16:36 pm
Just sent you a PM.
Title: Re: Problem resizing or creating thumbnails
Post by: pckconsult on June 14, 2012, 11:03:35 pm
It has worked well until some weeks ago, and I haven't uploaded photos, changed cpg core files or any settings from then on.
I tried with different jpg files bigger and smaller than 1285px (my max size for original pic).

I've read the troubleshooter and created a test account.
username: cpg_test
pwd: problem

I know I have had this issue before, can't remember, it has been a while... something to do with theme validation...
http://validator.w3.org/check?uri=http%3A%2F%2Fwww.flapane.com%2Fgallery%2F&charset=%28detect+automatically%29&doctype=Inline&group=0
(your theme is making the browser take it's best guess)

Maybe change theme to a standard out of the box theme, and test it...?
Hope this helps
-PCK
Title: Re: Problem resizing or creating thumbnails
Post by: flapane on June 15, 2012, 09:09:14 am
Hi, for whatever reason, today w3c fails to read the doctype of the theme which is xhtml transitional indeed, which leads to 10 errors. They're non-critical, though.
I tried using a vanilla theme without custom header and footer, however nothing changed. Thanks
Title: Re: Problem resizing or creating thumbnails
Post by: Αndré on June 15, 2012, 01:11:12 pm
You're currently using ImageMagick as resize method. Please try GD2.
Title: Re: Problem resizing or creating thumbnails
Post by: flapane on June 15, 2012, 01:18:14 pm
GD2 does is work flawlessy.
Before writing the OP, I asked my hosting if there was something wrong with imagemagik, because I couldn't resize images, and they told me that nothing changed.
I've been using IM since a couple of years or so for resizing images in the gallery. I wonder what's wrong.
Title: Re: Problem resizing or creating thumbnails
Post by: flapane on June 18, 2012, 06:02:48 pm
I've received an answer from my hosting, they told me that the error is due to line 71 of db_input.php, because this line of code doesn't use ImageMagik.

if (!$superCage->get->keyExists('event') && !$superCage->post->keyExists('event')) {
cpg_die(CRITICAL_ERROR, $lang_errors['param_missing'], __FILE__, __LINE__);

Honestly, I don't know what to say.
Title: Re: Problem resizing or creating thumbnails
Post by: Αndré on June 19, 2012, 08:43:20 am
That doesn't make sense to me, sorry.
Title: Re: Problem resizing or creating thumbnails
Post by: flapane on June 19, 2012, 09:26:09 am
Yep, actually it doesn't for me neither, but I had to report the answer they gave me... I'm waiting for a new answer from my hosting.

I wonder what could cause Imagemagik to stop working all of a sudden.
Title: Re: Problem resizing or creating thumbnails
Post by: flapane on June 20, 2012, 06:02:39 pm
They keep saying that the error is related to line 71 and not to Imagemagik.
I don't understand how they found something wrong with line 71, if cpg clearly states that the problem is on line 699.
Title: Re: Problem resizing or creating thumbnails
Post by: Αndré on June 21, 2012, 12:35:32 pm
I don't understand how they found something wrong with line 71
I assume they just put that URL into their browser: http://www.flapane.com/gallery/db_input.php and of course get the following error message
Quote
Critical error
Script called without the required parameter(s).

File: /home/flapanec/public_html/gallery/db_input.php - Line: 71

.......  :o ::)
Title: Re: Problem resizing or creating thumbnails
Post by: flapane on June 21, 2012, 12:55:23 pm
oh my...
They didn't even bother reading what I wrote.
Title: Re: Problem resizing or creating thumbnails
Post by: flapane on June 21, 2012, 03:01:50 pm
They told me another time that they don't have any problems and I'd better contact cpg developer (as if I hadn't already told them what we wrote in this thread...).
"Disappointed" is the right word, I guess. I may consider migrating elsewhere when the annual subscription expires.
Title: Re: Problem resizing or creating thumbnails
Post by: flapane on June 22, 2012, 11:09:17 pm
I've also just tried reinstalling 1.5.20 on the top of itself and disabling the plugins. Needless to say, nothing changed (after all, the problem first appeared all of a sudden without any changing to the code, so reinstalling cpg couldn't have helped).
Title: Re: Problem resizing or creating thumbnails
Post by: Αndré on June 23, 2012, 10:52:40 am
Maybe a test with a different software that also uses ImageMagick will approve our assumption that there's something wrong with ImageMagick on your hosts part. But I don't know such a software.
Title: Re: Problem resizing or creating thumbnails
Post by: flapane on June 23, 2012, 03:15:43 pm
That's a good idea. I'll keep you updated in case I found some PHP script which uses IM.
Title: Re: Problem resizing or creating thumbnails
Post by: flapane on June 23, 2012, 05:58:13 pm
This code succesfully created a thumbnail:
Code: [Select]
<?php
 
/*
A simple example demonstrate thumbnail creation.
*/ 
 
/* Create the Imagick object */
$im = new Imagick();
 
/* Read the image file */
$im->readImage'test.jpg' );
 
/* Thumbnail the image ( width 100, preserve dimensions ) */
$im->thumbnailImage100null );
 
/* Write the thumbail to disk */
$im->writeImage'th_test.jpg' );
 
/* Free resources associated to the Imagick object */
$im->destroy();
 
?>

Title: Re: Problem resizing or creating thumbnails
Post by: Αndré on June 23, 2012, 10:02:16 pm
But Imagick isn't ImageMagick, right?
Title: Re: Problem resizing or creating thumbnails
Post by: flapane on June 23, 2012, 10:10:35 pm
Quote
PHP.net: IMagick is a native PHP extension to create and modify images using the ImageMagick API.
Provides a wrapper to the ImageMagick library.

should I try a different php script?
Title: Re: Problem resizing or creating thumbnails
Post by: Joe Carver on June 24, 2012, 12:49:19 pm
What do you have for the setting in Config >> File settings   >> Additional command line options for ImageMagick  ?
Could the value have been corrupted in the db?

Please attach a screenshot of that setting.
Title: Re: Problem resizing or creating thumbnails
Post by: flapane on June 24, 2012, 01:00:21 pm
Yep, one of the first thing I did was deleting every additional CLI setting (which has been -antialias -unsharp 0.7x0.5+0.7+0.008 for the last couple of years or so) from that textfield, but nothing changed.
I wonder if the setting still remained in the sql dbase and eventually corrupted. Do I have to search for a specific sql db field in order to check this?
Thanks
Title: Re: Problem resizing or creating thumbnails
Post by: Αndré on June 25, 2012, 09:26:46 am
Do I have to search for a specific sql db field in order to check this?
That setting is stored in the config table. Search for the row with the name "im_options".
Title: Re: Problem resizing or creating thumbnails
Post by: flapane on June 25, 2012, 10:42:20 am
It looks empty as it should be
Title: Re: Problem resizing or creating thumbnails
Post by: Αndré on June 25, 2012, 11:30:07 am
As GD2 works as expected, isn't that thread already solved? I just wanted to debug $output and $retval in your gallery, but unfortunately it seems that my FTP account to your gallery doesn't exist anymore. Of course IM must be chosen in the config if you want me to debug that values. Maybe it brings some light into the darkness.
Title: Re: Problem resizing or creating thumbnails
Post by: flapane on June 25, 2012, 11:40:18 am
FTP account was temporary disabled for security reasons, please try again.
Maybe the title should be changed to "IM: Problem resizing or creating thumbnails", because the control granted to the user by IM command line options is vital.
The weird things are that it stopped working all of a sudden a couple of weeks ago, and IM *seems* to work using a test script, and that reinstalling cpg on top of itself didn't solve.
Thanks
Title: Re: Problem resizing or creating thumbnails
Post by: Αndré on June 25, 2012, 12:33:18 pm
PHP tries to execute the following command:
Quote
/usr/bin/convert -quality 80 -geometry 100x74 -unsharp 0.5x0.707106781187+1.2+0.03

As you can see, both the source and destination file strings are missing. The reason is the function escapeshellarg:
Quote
            if (preg_match("#[A-Z]:|\\\\#Ai", __FILE__)) {
                // get the basedir, remove '/include'
                $cur_dir = substr(dirname(__FILE__), 0, -8);
                $src_file = '"' . $cur_dir . '\\' . strtr($src_file, '/', '\\') . '"';
                $im_dest_file = str_replace('%', '%%', ('"' . $cur_dir . '\\' . strtr($dest_file, '/', '\\') . '"'));
            } else {
                $src_file = escapeshellarg($src_file);
                $im_dest_file = str_replace('%', '%%', escapeshellarg($dest_file));
            }

For some reason that function returns empty strings. Please ask your host about that function. Here's a test script and its output:
Code: [Select]
$test = "test";
var_dump($test);
echo "\n";
var_dump(escapeshellarg($test));
Quote
string(4) "test"
NULL
Title: Re: Problem resizing or creating thumbnails
Post by: flapane on June 25, 2012, 12:35:12 pm
Thanks, I'm gonna write them another message.
Title: Re: Problem resizing or creating thumbnails
Post by: flapane on June 26, 2012, 10:34:29 am
They said that escapeshellarg() has always been disabled because of security reasons, so probably I never noticed the problem because Coppermine started using on the latest release only.
---

I wonder if it's actually been introduced in 1.5.20 only.
Title: Re: Problem resizing or creating thumbnails
Post by: Αndré on June 26, 2012, 11:28:06 am
I don't know when it has been introduced, but it hasn't been introduced recently, as it's also been used in cpg1.4.x.
Title: Re: Problem resizing or creating thumbnails
Post by: flapane on June 26, 2012, 11:41:22 am
So I guess they lied for whatever reason. I understand their security concerns, but the fact that it's always been disabled is clearly a lie.
I guess I have to stick to GD as soon as I find another hosting. That's annoying, I'm not satisfied at all with the sharpness of the images produced by GD.

Out of curiosity, do we have any other ways for passing arguments to the shell via PHP? It seems that quite a few hostings around the world disabled escapeshellarg() in the last years.

Andre, thanks for your support.
Title: Re: Problem resizing or creating thumbnails
Post by: Αndré on June 26, 2012, 11:53:47 am
do we have any other ways for passing arguments to the shell via PHP?
It's not a matter of how to pass arguments, but how to escape specific characters in arguments. In that particular case it should be save to escape some characters like the single quote and put the whole argument in single quotes (at least that's what I understand what escapeshellarg does) if you're the only person who has permissions to upload pictures to your gallery. Regarding the security issue I found this (http://osvdb.org/show/osvdb/6737) article, which says that the security flaw has been fixed in PHP 4.3.7.
Title: Re: Problem resizing or creating thumbnails
Post by: flapane on June 26, 2012, 11:57:30 am
Who knows, maybe they don't trust of the customers themselves, I guess (customers could launch heavy load processes or whatever).
Title: Re: Problem resizing or creating thumbnails
Post by: Αndré on June 26, 2012, 12:18:20 pm
Then they have to disable the exec function. escapeshellarg seems to be the number one choice for shell arguments what mysql_real_escape_string is for whole MySQL query strings.
Title: Re: Problem resizing or creating thumbnails
Post by: flapane on June 26, 2012, 12:31:09 pm
Bingo. In fact I had to use mysql_real_escape_string in the guestbook I recently wrote for my website in order to avoid injections. I'm gonna tell them, but I suspect that things won't change.