Yii Framework Forum: [extension] Image issue - Yii Framework Forum

Jump to content

Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

[extension] Image issue error while trying to resize and save image Rate Topic: -----

#1 User is offline   Karasko 

  • Junior Member
  • Pip
  • Yii
  • Group: Members
  • Posts: 89
  • Joined: 14-July 09
  • Location:Russia

Posted 19 July 2009 - 06:36 PM

Hi, everyone.

I'm trying to resize sample image and save it, using Image extension with ImageMagick, platform WINXP

here is resize code:

Quote

$image = Yii::app()->image->load('c:/1.jpg');
/*@var $image Image */
$image->resize(400,300);
$image->save();


config code:

Quote

...
'image'=>array(
'class'=>'application.extensions.image.CImageComponent',
// GD or ImageMagick
'driver'=>'ImageMagick',
// ImageMagick setup path
'params'=>array('directory'=>'C:/Program Files/ImageMagick/'),
),


While executing resize action, i
get PHP error

Quote

Description

unlink(k2img--b73cbdf48c46ec2cbde88b5c3715f7ee09babf10.JPG) [<a href='function.unlink'>function.unlink</a>]: No such file or directory
Source File

C:\root\rus\www\protected\extensions\image\drivers\ImageMagick.php(112)

00100: header('Content-Type: image/gif');
00101: break;
00102: case 'png':
00103: header('Content-Type: image/png');
00104: break;
00105: }
00106: echo $contents;
00107: }
00108: }
00109: }
00110:
00111: // Remove the temporary image
00112: unlink($this->tmp_image);
00113: $this->tmp_image = '';
00114:
00115: return $status;
00116: }
00117:
00118: public function crop($prop)
00119: {
00120: // Sanitize and normalize the properties into geometry
00121: $this->sanitize_geometry($prop);
00122:
00123: // Set the IM geometry based on the properties
00124: $geometry = escapeshellarg($prop['width'].'x'.$prop['height'].'+'.$prop['left'].'+'.$prop['top']);

Stack Trace

#0 C:\root\rus\www\protected\extensions\image\drivers\ImageMagick.php(112): unlink()
#1 C:\root\rus\www\protected\extensions\image\Image.php(334): Image_ImageMagick_Driver->process()
#2 C:\root\rus\www\protected\controllers\SiteController.php(113): Image->save()
#3 C:\root\yii\framework\web\actions\CInlineAction.php(32): SiteController->actionImage()
#4 C:\root\yii\framework\web\CController.php(300): CInlineAction->run()
#5 C:\root\yii\framework\web\CController.php(278): SiteController->runAction()
#6 C:\root\yii\framework\web\CController.php(257): SiteController->runActionWithFilters()
#7 C:\root\yii\framework\web\CWebApplication.php(332): SiteController->run()
#8 C:\root\yii\framework\web\CWebApplication.php(120): CWebApplication->runController()
#9 C:\root\yii\framework\base\CApplication.php(133): CWebApplication->processRequest()
#10 C:\root\rusdom2000\www\index.php(11): CWebApplication->run()


Temp file with name "k2img--b73cbdf48c46ec2cbde88b5c3715f7ee09babf10.JPG" exists on disk C... Kinda weird it can't remove it..
Any advise ?
0

#2 User is offline   pestaa 

  • past Yii dev member
  • PipPipPipPip
  • Yii
  • Group: Members
  • Posts: 705
  • Joined: 07-May 09
  • Location:Hungary

Posted 20 July 2009 - 01:27 AM

As you haven't included any path information regarding temp folder or temp file parent folder, I suspect that ImageMagick wants to find the temporary image in the wrong place.
0

#3 User is offline   Karasko 

  • Junior Member
  • Pip
  • Yii
  • Group: Members
  • Posts: 89
  • Joined: 14-July 09
  • Location:Russia

Posted 20 July 2009 - 09:44 AM

View Postpestaa, on 20 July 2009 - 01:27 AM, said:

As you haven't included any path information regarding temp folder or temp file parent folder, I suspect that ImageMagick wants to find the temporary image in the wrong place.


As i know there is no config parameter like 'temp folder', unlink function is called by php, not ImageMagick.
Temporary image created in the same folder, where original image is.
0

#4 User is offline   pestaa 

  • past Yii dev member
  • PipPipPipPip
  • Yii
  • Group: Members
  • Posts: 705
  • Joined: 07-May 09
  • Location:Hungary

Posted 20 July 2009 - 10:56 AM

Please rewrite the corresponding unlink call, so that it uses absolute path.

It is highly likely that ImageMagick uses wrong path information and tries to remove temporary files from the folder where entry script (probably index.php) is.

I can't think of anything else, as Windowses are totally comfortable with php's unlink function.
0

#5 User is offline   Karasko 

  • Junior Member
  • Pip
  • Yii
  • Group: Members
  • Posts: 89
  • Joined: 14-July 09
  • Location:Russia

Posted 21 July 2009 - 05:09 AM

View Postpestaa, on 20 July 2009 - 10:56 AM, said:

Please rewrite the corresponding unlink call, so that it uses absolute path.

It is highly likely that ImageMagick uses wrong path information and tries to remove temporary files from the folder where entry script (probably index.php) is.

I can't think of anything else, as Windowses are totally comfortable with php's unlink function.


I tried to debug, and find out that exec() calls to ImageMagick don't work, but parameters (path to IM, image files) seems to be correct. It works ok from command line, but sucks in exec().
Unlink() doesn't work, because such file wasn't created by ImageMagick convert.exe.
0

#6 User is offline   pestaa 

  • past Yii dev member
  • PipPipPipPip
  • Yii
  • Group: Members
  • Posts: 705
  • Joined: 07-May 09
  • Location:Hungary

Posted 21 July 2009 - 06:10 AM

Is ImageMagick.php only a wrapper for the extension? I wasn't familiar with that, sorry. I thought PHP has built-in functions to manipulate images with IM.

Are you sure exec() is allowed in your scripts? I'd check that in the first place. I don't think this is the reason though.
0

#7 User is offline   Karasko 

  • Junior Member
  • Pip
  • Yii
  • Group: Members
  • Posts: 89
  • Joined: 14-July 09
  • Location:Russia

Posted 21 July 2009 - 07:05 PM

View Postpestaa, on 21 July 2009 - 06:10 AM, said:

Is ImageMagick.php only a wrapper for the extension? I wasn't familiar with that, sorry. I thought PHP has built-in functions to manipulate images with IM.

Are you sure exec() is allowed in your scripts? I'd check that in the first place. I don't think this is the reason though.

Yep. ImageMagick.php is only a wrapper for command line tools.

I don't know the reason why exec() can be disallowed :rolleyes:
Switched to GD2 temporary, it works...
But still wait for some advise :blink:
0

Share this topic:


Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

1 User(s) are reading this topic
0 members, 1 guests, 0 anonymous users