function mymodule_file_presave($file) {
// Change the file timestamp to an hour prior.
if($file->type=='image')
{

$image_file = $file->uri;
$image_name= $file->filename;
$file_full_url= file_create_url($image_file);
$url = $image_file;
$destination_folder =$image_file;
$newfname = $destination_folder;

if($file->filemime=='image/jpeg')
{
$file = fopen ($url, "rb");
if ($file)
{
$filename=$newfname;
$img = imagecreatefromjpeg($filename);
header("Content-Type: image/jpeg");
imagejpeg($img, $filename, 50);
}
if ($file)
{
fclose($file);
}
}
else if($file->filemime=='image/png')
{
$file = fopen ($url, "rb");
if ($file)
{
$filename=$newfname;
$img = imagecreatefrompng($filename);
header("Content-Type: image/jpeg");
imagejpeg($img, $filename, 50);
}
if ($file)
{
fclose($file);
}

}
else if($file->filemime=='image/gif')
{
$file = fopen ($url, "rb");
if ($file)
{
$filename=$newfname;
$img = imagecreatefrompng($filename);
header("Content-Type: image/jpeg");
imagejpeg($img, $filename, 50);
}
if ($file)
{
fclose($file);
}
}

}

}

Comments

joachim’s picture

Status: Active » Closed (outdated)

This is not the right project for issues on core.