Posting in the Magento forums has been disabled pending the implementation of a new and improved forum solution which should better serve the community.

For new questions please post at magento.stackexchange.com, the community-run support site for the Magento community. We will be providing updates on the new forum solution soon. For questions or concerns please email community@magento.com.

Magento Forum

How to rename image file in magento
 
Nils123
Jr. Member
 
Total Posts:  3
Joined:  2009-12-21
 

Hi all,
I had designed the product customization module for product and i am able to save the new customized image at new location say /magento/tempimg/myimg.jpeg. now when the order is placed (i.e. checkout is done) i want to rename this image with the order number generated. So I am trying to rename this file in magento/app/design/frontend/default/default/template/checkout/success.phtml. I am trying to do this using image GD library. but i am constantly getting the error Warning: imagepng() [function.imagepng]: Unable to open ‘img path’ for writing: No such file or directory in ....../magento/app/design/frontend/default/default/template/checkout/success.phtml.

the image code:
$newimgname = “http://localhost/magento/tempimg/”.$this->getOrderId()."_”.$_SESSION[’itemno’].".png";
$im = imagecreatefromjpeg(’mysource img’); //i.e. ../magento/tempimg/myimg.jpeg

$width = imagesx($im);
$height = imagesy($im);

$im_dest=imagecreatetruecolor($width, $height);

imagecopy($im_dest,$im,0,$height,0, $height,$width, $height);

header(’Content-type: image/jpeg’);
imagepng($im_dest,$newimgname);

imagedestroy($im);
imagedestroy($im_dest);

Any idea what i am doing worng.

Any help would be great..

Thanks in Advance..
Nils123

 
Magento Community Magento Community
Magento Community
Magento Community
 
Nils123
Jr. Member
 
Total Posts:  3
Joined:  2009-12-21
 

header(’Content-type: image/jpeg’);

has been changed to

header(’Content-type: image/png’);

but still the same…

 
Magento Community Magento Community
Magento Community
Magento Community
Magento Community
Magento Community
Back to top