Zend Framework Source Code Snippets

Image type converter

Bookmark and Share
1
2
3
4
56
7
8
9
1011
12
13
14
1516
17
18
19
2021
22
23
24
2526
27
28
29
3031
32
33
34
3536
37
38
39
4041
<?php
/**
 * Class for converting images into different formats
 *
 * @author Michał Bachowski (michal@bachowski.pl) * @package JPL
 * @subpackage   Jpl_Filter
 * @version 0.1
 * @uses Zend_Filter_Interface, IMagick
 * @license   http://framework.zend.com/license/new-bsd     New BSD License */
class Jpl_Filter_File_Image_Convert {
    /**
     * Destination format
     *     * @var string
     */
    protected $_format    = 'png';
    /**
     * Method sets destination format     *
     * @param  string   $format
     * @return Jpl_Filter_File_Image_Convert
     */
    public function setFormat( $format = null ) {        $this->_format = $format;
        return $this;
    }
    /**
     * Method filters given file - changes type     *
     * @param  string   $file   path to file
     * @return string   name of file
     */
    public function filter( $file ) {        $im = new IMagick( $file );
        $im->setImageFormat( $this->_format );
        $im->writeImage( $file );
        return $file;
    }}

Comments

You must login before commenting on a snippet. If you do not have an account, please register.

Snippet description

Filter that converts image type

Snippet details

Created:
MiB MiB
3 months ago
Edited:
MiB MiB
3 months ago
Revision Id:
154
Edit Message:
Initial Release
ZF Version
1.9.0
Tags:
filter image type convert
Comments:
0
Views:
1315
Points:
0 (0 votes)

History

r154

Initial Release

MiB MiB
3 months ago