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 change the image dpi in magento Controller action. 
 
muk_t
Sr. Member
 
Total Posts:  226
Joined:  2012-07-24
 

Hi,

I want to change an image dpi using controller action in magento.I want to convert images to jpg from png then convert quality to 200dpi.
I have following code in controller which I am calling using Ajax call

Code for iamge conversion is like following.

public function pngtojpgAction()   
    
{
                        
//Code to convert png to jpg image
            
$input imagecreatefrompng($this->getRequest()->getParam('imagedata'));
            
$width=imagesx($input);
            
$height=imagesy($input);
            
$output imagecreatetruecolor($width$height);
            
$white imagecolorallocate($output,  255255255);
            
imagefilledrectangle($output00$width$height$white);
            
imagecopy($output$input0000$width$height);            
             
            
ob_start();
            
imagejpeg($output);
            
$contents =  ob_get_contents();
            
ob_end_clean();
            echo 
'data:image/jpeg;base64,'.base64_encode($contents);
    
}

But how to convert image quality?

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