\n"; echo "optional args: resize=nnn rotate=nnn
\n"; exit(1); } $infile = $img; $outfile = tempnam(variable_get('file_directory_temp', FILE_DIRECTORY_TEMP), 'itktest'); // perform the manipulation if ($resize) { $ret = image_scale($infile, $outfile, $resize, $resize); if (!$ret) { echo "image scale failed
\n"; exit(0); } $infile = $outfile; } if ($rotate) { $ret = image_rotate($infile, $outfile, $rotate); if (!$ret) { echo "image rotate failed
\n"; exit(0); } } // stream the image $headers = array( 'Content-Type: image/jpeg', 'Content-Length: '. filesize($outfile), 'Content-Disposition: filename="'.basename($img), ); ob_end_clean(); foreach ($headers as $header) { $header = preg_replace('/\r?\n(?!\t| )/', '', $header); header($header); } // Transfer file in 1024 byte chunks to save memory usage. if ($fd = fopen($outfile, 'rb')) { while (!feof($fd)) { print fread($fd, 1024); } fclose($fd); // remove the file } unlink($outfile); ?>