Page 1 of 1

running tshirt in PHP returns .jpg2 and .cache files

Posted: 2015-04-29T18:18:19-07:00
by spchuang
HI,

I'm running Fred's tshirt script in php using exec, and the results are .jpg2 and .cache files.

Code: Select all

exec("./tshirt -r '325x325+36+40' -f distort {$url} ../test/tshirt.jpg ../test/test.jpg");
The data for .jpg2 is the following which seems to be some kind of configuration

Code: Select all

id=MagickCache
magick-signature=4026865107
class=DirectClass  colors=0  matte=False
columns=400  rows=400 depth=8
colorspace=sRGB
compression=JPEG  quality=80
page=400x400+0+0
rendering-intent=Perceptual
gamma=0.454545
red-primary=0.64,0.33  green-primary=0.3,0.6  blue-primary=0.15,0.06
white-point=0.3127,0.329
date:create=2015-04-30T03:14:58+02:00
date:modify=2015-04-30T03:14:58+02:00
jpeg:colorspace=2
jpeg:sampling-factor=1x1,1x1,1x1

:
I ran the same script in command line and resulted in the correct .jpg file.

Does anyone know why this is happening?

Version: ImageMagick 6.9.1-2

Re: running tshirt in PHP returns .jpg2 and .cache files

Posted: 2015-04-29T19:48:40-07:00
by fmw42
If you ran it successfully in the command line, then the script is fine.

You may have a problem with PHP if you did not apply the Pointers from my home page for usage with PHP. Also your PHP may be calling some other Imagemagick version or may not be properly configured.


Run this to see if you get any error messsages.

Code: Select all

<?php
exec("./tshirt -r '325x325+36+40' -f distort {$url} ../test/tshirt.jpg ../test/test.jpg 2>&1",$out,$returnval);
foreach($out as $text)
{echo "$text<br>";}
?>
Is $url a file on your system or being accessed from the web via http://.....?

If the latter, then I have no idea how PHP works with http accessed files.

Is this being run from some web site? If so, what is the web site url?

Re: running tshirt in PHP returns .jpg2 and .cache files

Posted: 2015-04-30T15:52:51-07:00
by spchuang
{$url} is the path to the image file in the directory (../directory/file.jpg)

There isn't any error when i run the script.

The imagemagick version being called by PHP is 6.9.1-2

The website is still under testing.

Re: running tshirt in PHP returns .jpg2 and .cache files

Posted: 2015-04-30T16:13:37-07:00
by snibgo
In PHP, do relative paths to images work? Don't they need to be absolute paths?

Re: running tshirt in PHP returns .jpg2 and .cache files

Posted: 2015-04-30T16:58:45-07:00
by fmw42
Did you make all the changes from my Pointers on my home page?

I can only surmise that something is wrong with your PHP setup or command. I am not an expert on PHP. Does PHP allow single quotes inside of your PHP outer quotes? Do the inner ones need escaping?

Try putting your images in the same directory as the script? Does that help with regard to snibgo's comments?

Try running a simple IM command

exec("convert rose: rose.jpg")

Does that work? If so, then try a simpler script such as 2colorthresh. Does that work?

When you downloaded the script, does the file have .sh appended? If so, then you need to change it or the PHP command to be consistent.

Do you have proper permissions for your PHP?

Try adding bash to your command as

Code: Select all

<?php
exec("bash ./tshirt -r '325x325+36+40' -f distort {$url} ../test/tshirt.jpg ../test/test.jpg 2>&1",$out,$returnval);
foreach($out as $text)
{echo "$text<br>";}
?>
Does your tmp directory have enough disk space?

There is no jpg2 file created in my script. That could only come from your $url.

The .cache files are created with corresponding .mpc files that are created as tmp files in the script and should go away automatically. What are the full filenames for the .jpg2 and .cache files?

The script creates a temp folder to contain all the images and the temp folder gets deleted automatically. So there should be no .cache files remaining if the folder is properly deleted. Check your tmp directory to see what is there and if close to full? Any of them contain the name imagemagick?

Try changing lines 380,381,382 from

trap "rm -rf $dir;" 0
trap "rm -rf $dir; exit 1" 1 2 3 10 15
trap "rm -rf $dir; exit 1" ERR

to

trap "rm -rf $dir; exit 0" 0
trap "rm -rf $dir; exit 1" 1 2 3 10 15

Does that make a difference?

Re: running tshirt in PHP returns .jpg2 and .cache files

Posted: 2015-04-30T18:12:55-07:00
by spchuang
For some reason, this issue is gone when I ran the script again today...

I don't know what has changed since yesterday, but I suppose the issue is gone.

Thank you for your help!