Created
November 24, 2014 10:37
-
-
Save indapublic/d1869e98c74369178934 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<? | |
require_once '../../CImage.php'; | |
$sourceFileName = '../../webroot/img/issue40/1280x720.jpg'; | |
$resultFileName = '../../webroot/img/issue40/652x466.jpg'; | |
$imgOptions = array( | |
'newWidth' => 652, | |
'newHeight' => 466, | |
'no-ratio' | |
); | |
$img = new CImage(); | |
$img->setSource(basename($sourceFileName), dirname($sourceFileName)) | |
->setOptions($imgOptions) | |
->loadImageDetails() | |
->initDimensions() | |
->calculateNewWidthAndHeight() | |
->setSaveAsExtension('jpg') | |
/* | |
->setJpegQuality(70) | |
->setPngCompression(NULL) | |
->useOriginalIfPossible(TRUE) | |
->useCacheIfPossible(FALSE) | |
*/ | |
->load() | |
->preResize() | |
->resize() | |
->postResize() | |
->setPostProcessingOptions(array( | |
'png_filter' => FALSE, | |
'png_deflate' => FALSE, | |
'jpeg_optimize' => FALSE | |
)) | |
->save(basename($resultFileName), dirname($resultFileName)); | |
if (!file_exists($resultFileName)) | |
die('Result file is not exists :('); | |
$resultFileSizes = getimagesize($resultFileName); | |
echo $resultFileSizes[0] . 'x' . $resultFileSizes[1]; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment