-
Notifications
You must be signed in to change notification settings - Fork 28
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Improved performance and keepFrame support.
- Loading branch information
Karl Spies
authored and
Karl Spies
committed
Jan 16, 2013
1 parent
3ae918a
commit 670423a
Showing
4 changed files
with
174 additions
and
16 deletions.
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -105,5 +105,5 @@ skin/frontend/default/modern/ | |
skin/frontend/enterprise | ||
skin/install/ | ||
var/ | ||
|
||
.idea/* | ||
data |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,4 @@ | ||
src/app/code/community/FireGento/PerfectWatermarks/ app/code/community/FireGento/PerfectWatermarks/ | ||
src/app/etc/modules/FireGento_PerfectWatermarks.xml app/etc/modules/FireGento_PerfectWatermarks.xml | ||
src/app/code/community/Varien/Image/Adapter/Imagemagic.php app/code/community/Varien/Image/Adapter/Imagemagic.php | ||
src/shell/* shell |
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,77 @@ | ||
<?php | ||
require_once 'abstract.php'; | ||
|
||
class Image_Batch_Performance extends Mage_Shell_Abstract | ||
{ | ||
|
||
/** | ||
* Run script | ||
* | ||
*/ | ||
public function run() | ||
{ | ||
|
||
if (!$this->getArg('d')) { | ||
return $this->usageHelp(); | ||
} | ||
/** @var $iterator SplFileObject[] */ | ||
$iterator = new DirectoryIterator($this->getArg('d')); | ||
$start = microtime(true); | ||
$i = 0; | ||
$max = 0; | ||
do { | ||
foreach ($iterator as $file) { | ||
if (!$file->isDir()) { | ||
$image = new Varien_Image( | ||
$this->getArg('d') . DS . $file->getFilename(), | ||
Varien_Image_Adapter::ADAPTER_IM | ||
); | ||
$image->keepFrame(true); | ||
$image->keepAspectRatio(true); | ||
$image->keepTransparency(true); | ||
$image->backgroundColor('000', '000', '000'); | ||
$image->resize(186, 500); | ||
$image->setWatermarkImageOpacity(100); | ||
$image->setWatermarkPosition( | ||
Varien_Image_Adapter_Abstract::POSITION_TOP_LEFT | ||
); | ||
$image->setWatermarkHeigth(100); | ||
$image->setWatermarkWidth(100); | ||
$image->quality(80); | ||
$watermark = | ||
$this->getArg('d') . DS . 'watermark' . DS . 'watermark.png'; | ||
if (is_readable($watermark)) { | ||
$image->watermark($watermark); | ||
} | ||
$image->save( | ||
$this->getArg('d') . DS . 'result', $file->getFilename() | ||
); | ||
} | ||
} | ||
} while ($i++ < $max); | ||
$endMem = memory_get_usage(true); | ||
$end = microtime(true); | ||
|
||
echo "Duration in seconds: " . (($end - $start)) . PHP_EOL; | ||
echo "Memory usage in MB: " . (($endMem / 1024) / 1024) . PHP_EOL; | ||
} | ||
|
||
/** | ||
* Retrieve Usage Help Message | ||
* | ||
*/ | ||
public function usageHelp() | ||
{ | ||
return <<<USAGE | ||
Usage: php -f imagemagicktest.php -- [options] | ||
-h Short alias for help | ||
-d directory with sample data | ||
help This help | ||
USAGE; | ||
} | ||
} | ||
|
||
$imageBatch = new Image_Batch_Performance(); | ||
$imageBatch->run(); |