/library/filemanager/filemanager/include/php_image_magician.php

.htaccess
LICENSE
PHPMailer
    .gitignore
    .scrutinizer.yml
    .travis.yml
    LICENSE
    PHPMailerAutoload.php
    README.md
    VERSION
    changelog.md
    class.phpmailer.php
    class.pop3.php
    class.smtp.php
    composer.json
    docs
        Callback_function_notes.txt
        DomainKeys_notes.txt
        Note_for_SMTP_debugging.txt
        extending.html
        faq.html
        generatedocs.sh
        pop3_article.txt
    examples
        code_generator.phps
        contents.html
        contentsutf8.html
        exceptions.phps
        gmail.phps
        images
            phpmailer.png
            phpmailer_mini.png
        index.html
        mail.phps
        mailing_list.phps
        pop_before_smtp.phps
        scripts
            XRegExp.js
            shAutoloader.js
            shBrushPhp.js
            shCore.js
            shLegacy.js
        send_file_upload.phps
        sendmail.phps
        smtp.phps
        smtp_check.phps
        smtp_no_auth.phps
        ssl_options.phps
        styles
            shCore.css
            shCoreDefault.css
            shCoreDjango.css
            shCoreEclipse.css
            shCoreEmacs.css
            shCoreFadeToGrey.css
            shCoreMDUltra.css
            shCoreMidnight.css
            shCoreRDark.css
            shThemeAppleScript.css
            shThemeDefault.css
            shThemeDjango.css
            shThemeEclipse.css
            shThemeEmacs.css
            shThemeFadeToGrey.css
            shThemeMDUltra.css
            shThemeMidnight.css
            shThemeRDark.css
            shThemeVisualStudio.css
            wrapping.png
    extras
        EasyPeasyICS.php
        README.md
        htmlfilter.php
        ntlm_sasl_client.php
    language
        phpmailer.lang-am.php
        phpmailer.lang-ar.php
        phpmailer.lang-az.php
        phpmailer.lang-be.php
        phpmailer.lang-bg.php
        phpmailer.lang-br.php
        phpmailer.lang-ca.php
        phpmailer.lang-ch.php
        phpmailer.lang-cz.php
        phpmailer.lang-de.php
        phpmailer.lang-dk.php
        phpmailer.lang-el.php
        phpmailer.lang-eo.php
        phpmailer.lang-es.php
        phpmailer.lang-et.php
        phpmailer.lang-fa.php
        phpmailer.lang-fi.php
        phpmailer.lang-fo.php
        phpmailer.lang-fr.php
        phpmailer.lang-gl.php
        phpmailer.lang-he.php
        phpmailer.lang-hr.php
        phpmailer.lang-hu.php
        phpmailer.lang-id.php
        phpmailer.lang-it.php
        phpmailer.lang-ja.php
        phpmailer.lang-ka.php
        phpmailer.lang-ko.php
        phpmailer.lang-lt.php
        phpmailer.lang-lv.php
        phpmailer.lang-ms.php
        phpmailer.lang-nl.php
        phpmailer.lang-no.php
        phpmailer.lang-pl.php
        phpmailer.lang-pt.php
        phpmailer.lang-ro.php
        phpmailer.lang-ru.php
        phpmailer.lang-se.php
        phpmailer.lang-sk.php
        phpmailer.lang-sl.php
        phpmailer.lang-sr.php
        phpmailer.lang-tr.php
        phpmailer.lang-uk.php
        phpmailer.lang-vi.php
        phpmailer.lang-zh.php
        phpmailer.lang-zh_cn.php
    test
        bootstrap.php
        fakepopserver.sh
        fakesendmail.sh
        phpmailerLangTest.php
        phpmailerTest.php
        runfakepopserver.sh
        test_callback.php
        testbootstrap-dist.php
    travis.phpunit.xml.dist
application
    .htaccess
    cache
        .htaccess
        index.html
    config
        autoload.php
        config.php
        constants.php
        database.php
        doctypes.php
        foreign_chars.php
        hooks.php
        index.html
        memcached.php
        migration.php
        mimes.php
        profiler.php
        routes.php
        smileys.php
        user_agents.php
    controllers
        Ioattachment.php
        Ioexport.php
        Iogroups.php
        Ioimport.php
        Iomessages.php
        Iosendmanager.php
        Iosends.php
        Iosignatures.php
        Iotimetable.php
        Mailing.php
        Welcome.php
        index.html
    core
        index.html
    helpers
        index.html
    hooks
        index.html
    index.html
    language
        arabic
            calendar_lang.php
            date_lang.php
            db_lang.php
            email_lang.php
            form_validation_lang.php
            ftp_lang.php
            imglib_lang.php
            index.html
            migration_lang.php
            number_lang.php
            pagination_lang.php
            profiler_lang.php
            unit_test_lang.php
            upload_lang.php
        azerbaijani
            calendar_lang.php
            date_lang.php
            db_lang.php
            email_lang.php
            form_validation_lang.php
            ftp_lang.php
            imglib_lang.php
            index.html
            migration_lang.php
            number_lang.php
            pagination_lang.php
            profiler_lang.php
            unit_test_lang.php
            upload_lang.php
        bulgarian
            calendar_lang.php
            date_lang.php
            db_lang.php
            email_lang.php
            form_validation_lang.php
            ftp_lang.php
            imglib_lang.php
            index.html
            migration_lang.php
            number_lang.php
            pagination_lang.php
            profiler_lang.php
            unit_test_lang.php
            upload_lang.php
        catalan
            calendar_lang.php
            date_lang.php
            db_lang.php
            email_lang.php
            form_validation_lang.php
            ftp_lang.php
            imglib_lang.php
            index.html
            migration_lang.php
            number_lang.php
            pagination_lang.php
            profiler_lang.php
            unit_test_lang.php
            upload_lang.php
        czech
            calendar_lang.php
            date_lang.php
            db_lang.php
            email_lang.php
            form_validation_lang.php
            ftp_lang.php
            imglib_lang.php
            index.html
            migration_lang.php
            number_lang.php
            pagination_lang.php
            profiler_lang.php
            unit_test_lang.php
            upload_lang.php
        dutch
            calendar_lang.php
            date_lang.php
            db_lang.php
            email_lang.php
            form_validation_lang.php
            ftp_lang.php
            imglib_lang.php
            index.html
            migration_lang.php
            number_lang.php
            pagination_lang.php
            profiler_lang.php
            unit_test_lang.php
            upload_lang.php
        english
            index.html
            mailerattach_lang.php
            mailerexport_lang.php
            mailergroup_lang.php
            mailerimport_lang.php
            mailermailing_lang.php
            mailermain_lang.php
            mailermsg_lang.php
            mailersendmanager_lang.php
            mailersends_lang.php
            mailersignatures_lang.php
            mailertimetable_lang.php
        filipino
            calendar_lang.php
            date_lang.php
            db_lang.php
            email_lang.php
            form_validation_lang.php
            ftp_lang.php
            imglib_lang.php
            index.html
            migration_lang.php
            number_lang.php
            pagination_lang.php
            profiler_lang.php
            unit_test_lang.php
            upload_lang.php
        french
            calendar_lang.php
            date_lang.php
            db_lang.php
            email_lang.php
            form_validation_lang.php
            ftp_lang.php
            imglib_lang.php
            index.html
            migration_lang.php
            number_lang.php
            pagination_lang.php
            profiler_lang.php
            unit_test_lang.php
            upload_lang.php
        german
            calendar_lang.php
            date_lang.php
            db_lang.php
            email_lang.php
            form_validation_lang.php
            ftp_lang.php
            imglib_lang.php
            index.html
            migration_lang.php
            number_lang.php
            pagination_lang.php
            profiler_lang.php
            unit_test_lang.php
            upload_lang.php
        gujarati
            calendar_lang.php
            date_lang.php
            db_lang.php
            email_lang.php
            form_validation_lang.php
            ftp_lang.php
            imglib_lang.php
            index.html
            migration_lang.php
            number_lang.php
            pagination_lang.php
            profiler_lang.php
            unit_test_lang.php
            upload_lang.php
        hindi
            calendar_lang.php
            date_lang.php
            db_lang.php
            email_lang.php
            form_validation_lang.php
            ftp_lang.php
            imglib_lang.php
            index.html
            migration_lang.php
            number_lang.php
            pagination_lang.php
            profiler_lang.php
            unit_test_lang.php
            upload_lang.php
        hungarian
            calendar_lang.php
            date_lang.php
            db_lang.php
            email_lang.php
            form_validation_lang.php
            ftp_lang.php
            imglib_lang.php
            index.html
            migration_lang.php
            number_lang.php
            pagination_lang.php
            profiler_lang.php
            unit_test_lang.php
            upload_lang.php
        index.html
        indonesian
            calendar_lang.php
            date_lang.php
            db_lang.php
            email_lang.php
            form_validation_lang.php
            ftp_lang.php
            imglib_lang.php
            index.html
            migration_lang.php
            number_lang.php
            pagination_lang.php
            profiler_lang.php
            unit_test_lang.php
            upload_lang.php
        italian
            calendar_lang.php
            date_lang.php
            db_lang.php
            email_lang.php
            form_validation_lang.php
            ftp_lang.php
            imglib_lang.php
            index.html
            migration_lang.php
            number_lang.php
            pagination_lang.php
            profiler_lang.php
            unit_test_lang.php
            upload_lang.php
        japanese
            calendar_lang.php
            date_lang.php
            db_lang.php
            email_lang.php
            form_validation_lang.php
            ftp_lang.php
            imglib_lang.php
            index.html
            migration_lang.php
            number_lang.php
            pagination_lang.php
            profiler_lang.php
            unit_test_lang.php
            upload_lang.php
        khmer
            calendar_lang.php
            date_lang.php
            db_lang.php
            email_lang.php
            form_validation_lang.php
            ftp_lang.php
            imglib_lang.php
            index.html
            migration_lang.php
            number_lang.php
            pagination_lang.php
            profiler_lang.php
            unit_test_lang.php
            upload_lang.php
        korean
            calendar_lang.php
            date_lang.php
            db_lang.php
            email_lang.php
            form_validation_lang.php
            ftp_lang.php
            imglib_lang.php
            index.html
            migration_lang.php
            number_lang.php
            pagination_lang.php
            profiler_lang.php
            unit_test_lang.php
            upload_lang.php
        latvian
            calendar_lang.php
            date_lang.php
            db_lang.php
            email_lang.php
            form_validation_lang.php
            ftp_lang.php
            imglib_lang.php
            index.html
            migration_lang.php
            number_lang.php
            pagination_lang.php
            profiler_lang.php
            unit_test_lang.php
            upload_lang.php
        norwegian
            calendar_lang.php
            date_lang.php
            db_lang.php
            email_lang.php
            form_validation_lang.php
            ftp_lang.php
            imglib_lang.php
            index.html
            migration_lang.php
            number_lang.php
            pagination_lang.php
            profiler_lang.php
            unit_test_lang.php
            upload_lang.php
        persian
            calendar_lang.php
            date_lang.php
            db_lang.php
            email_lang.php
            form_validation_lang.php
            ftp_lang.php
            imglib_lang.php
            index.html
            migration_lang.php
            number_lang.php
            pagination_lang.php
            profiler_lang.php
            unit_test_lang.php
            upload_lang.php
        polish
            calendar_lang.php
            date_lang.php
            db_lang.php
            email_lang.php
            form_validation_lang.php
            ftp_lang.php
            imglib_lang.php
            index.html
            mailerattach_lang.php
            mailerexport_lang.php
            mailergroup_lang.php
            mailerimport_lang.php
            mailerinstall_lang.php
            mailermailing_lang.php
            mailermain_lang.php
            mailermsg_lang.php
            mailersendmanager_lang.php
            mailersends_lang.php
            mailersignatures_lang.php
            mailertimetable_lang.php
            migration_lang.php
            number_lang.php
            pagination_lang.php
            profiler_lang.php
            unit_test_lang.php
            upload_lang.php
        portuguese
            calendar_lang.php
            date_lang.php
            db_lang.php
            email_lang.php
            form_validation_lang.php
            ftp_lang.php
            imglib_lang.php
            index.html
            migration_lang.php
            number_lang.php
            pagination_lang.php
            profiler_lang.php
            unit_test_lang.php
            upload_lang.php
        portuguese-brazilian
            calendar_lang.php
            date_lang.php
            db_lang.php
            email_lang.php
            form_validation_lang.php
            ftp_lang.php
            imglib_lang.php
            index.html
            migration_lang.php
            number_lang.php
            pagination_lang.php
            profiler_lang.php
            unit_test_lang.php
            upload_lang.php
        romanian
            calendar_lang.php
            date_lang.php
            db_lang.php
            email_lang.php
            form_validation_lang.php
            ftp_lang.php
            imglib_lang.php
            index.html
            migration_lang.php
            number_lang.php
            pagination_lang.php
            profiler_lang.php
            unit_test_lang.php
            upload_lang.php
        russian
            calendar_lang.php
            date_lang.php
            db_lang.php
            email_lang.php
            form_validation_lang.php
            ftp_lang.php
            imglib_lang.php
            index.html
            migration_lang.php
            number_lang.php
            pagination_lang.php
            profiler_lang.php
            unit_test_lang.php
            upload_lang.php
        simplified-chinese
            calendar_lang.php
            date_lang.php
            db_lang.php
            email_lang.php
            form_validation_lang.php
            ftp_lang.php
            imglib_lang.php
            index.html
            migration_lang.php
            number_lang.php
            pagination_lang.php
            profiler_lang.php
            unit_test_lang.php
            upload_lang.php
        slovak
            calendar_lang.php
            date_lang.php
            db_lang.php
            email_lang.php
            form_validation_lang.php
            ftp_lang.php
            imglib_lang.php
            index.html
            migration_lang.php
            number_lang.php
            pagination_lang.php
            profiler_lang.php
            unit_test_lang.php
            upload_lang.php
        spanish
            calendar_lang.php
            date_lang.php
            db_lang.php
            email_lang.php
            form_validation_lang.php
            ftp_lang.php
            imglib_lang.php
            index.html
            migration_lang.php
            number_lang.php
            pagination_lang.php
            profiler_lang.php
            unit_test_lang.php
            upload_lang.php
        swedish
            calendar_lang.php
            date_lang.php
            db_lang.php
            email_lang.php
            form_validation_lang.php
            ftp_lang.php
            imglib_lang.php
            index.html
            migration_lang.php
            number_lang.php
            pagination_lang.php
            profiler_lang.php
            unit_test_lang.php
            upload_lang.php
        tamil
            calendar_lang.php
            date_lang.php
            db_lang.php
            email_lang.php
            form_validation_lang.php
            ftp_lang.php
            imglib_lang.php
            index.html
            migration_lang.php
            number_lang.php
            pagination_lang.php
            profiler_lang.php
            unit_test_lang.php
            upload_lang.php
        thai
            calendar_lang.php
            date_lang.php
            db_lang.php
            email_lang.php
            form_validation_lang.php
            ftp_lang.php
            imglib_lang.php
            index.html
            migration_lang.php
            number_lang.php
            pagination_lang.php
            profiler_lang.php
            unit_test_lang.php
            upload_lang.php
        traditional-chinese
            calendar_lang.php
            date_lang.php
            db_lang.php
            email_lang.php
            form_validation_lang.php
            ftp_lang.php
            imglib_lang.php
            index.html
            migration_lang.php
            number_lang.php
            pagination_lang.php
            profiler_lang.php
            unit_test_lang.php
            upload_lang.php
        turkish
            calendar_lang.php
            date_lang.php
            db_lang.php
            email_lang.php
            form_validation_lang.php
            ftp_lang.php
            imglib_lang.php
            index.html
            migration_lang.php
            number_lang.php
            pagination_lang.php
            profiler_lang.php
            unit_test_lang.php
            upload_lang.php
        ukrainian
            calendar_lang.php
            date_lang.php
            db_lang.php
            email_lang.php
            form_validation_lang.php
            ftp_lang.php
            imglib_lang.php
            index.html
            migration_lang.php
            number_lang.php
            pagination_lang.php
            profiler_lang.php
            unit_test_lang.php
            upload_lang.php
        urdu
            calendar_lang.php
            date_lang.php
            db_lang.php
            email_lang.php
            form_validation_lang.php
            ftp_lang.php
            imglib_lang.php
            index.html
            migration_lang.php
            number_lang.php
            pagination_lang.php
            profiler_lang.php
            unit_test_lang.php
            upload_lang.php
        vietnamese
            calendar_lang.php
            date_lang.php
            db_lang.php
            email_lang.php
            form_validation_lang.php
            ftp_lang.php
            imglib_lang.php
            index.html
            migration_lang.php
            number_lang.php
            pagination_lang.php
            profiler_lang.php
            unit_test_lang.php
            upload_lang.php
    libraries
        index.html
    logs
        index.html
    models
        Attachment_model.php
        Export_model.php
        Groups_model.php
        Import_model.php
        Mailing_model.php
        Messages_model.php
        Sendmanager_model.php
        Sends_model.php
        Signatures_model.php
        System_model.php
        Timetable_model.php
        Track_model.php
        User_model.php
        index.html
    third_party
        index.html
    views
        about.php
        aboutrights.php
        addnewuser.php
        attachment
            attachment.php
        changepassword.php
        changeprofiledata.php
        errors
            cli
                error_404.php
                error_db.php
                error_exception.php
                error_general.php
                error_php.php
                index.html
            html
                error_404.php
                error_db.php
                error_exception.php
                error_general.php
                error_php.php
                index.html
            index.html
        export
            group.php
        foot.php
        footpop.php
        generatenewpassword.php
        generatepassword.php
        groups
            addemail.php
            edit.php
            editemail.php
            excaddemail.php
            exclusion.php
            export.php
            import.php
            index.php
            viewgroup.php
        head.php
        headpop.php
        import
            group.php
            groupimport.php
        index.html
        licensefail.php
        login.php
        logindenied.php
        logs.php
        mainpage.php
        messages
            editmessage.php
            empty.php
            index.php
            reportmessage.php
            statmessage.php
        norights.php
        options.php
        sendmanager
            sender.php
        sends
            edit.php
            index.php
        signatures
            edit.php
            index.php
        team.php
        timetable
            edit.php
            index.php
        welcome_message.php
arial.ttf
attachment
captcha
    sys.txt
favicon.ico
import
index.php
install.php
library
    add.png
    ckeditor
        CHANGES.md
        LICENSE.md
        README.md
        adapters
            jquery.js
        build-config.js
        ckeditor.js
        config.js
        contents.css
        lang
            af.js
            ar.js
            bg.js
            bn.js
            bs.js
            ca.js
            cs.js
            cy.js
            da.js
            de.js
            el.js
            en-au.js
            en-ca.js
            en-gb.js
            en.js
            eo.js
            es.js
            et.js
            eu.js
            fa.js
            fi.js
            fo.js
            fr-ca.js
            fr.js
            gl.js
            gu.js
            he.js
            hi.js
            hr.js
            hu.js
            id.js
            is.js
            it.js
            ja.js
            ka.js
            km.js
            ko.js
            ku.js
            lt.js
            lv.js
            mk.js
            mn.js
            ms.js
            nb.js
            nl.js
            no.js
            pl.js
            pt-br.js
            pt.js
            ro.js
            ru.js
            si.js
            sk.js
            sl.js
            sq.js
            sr-latn.js
            sr.js
            sv.js
            th.js
            tr.js
            tt.js
            ug.js
            uk.js
            vi.js
            zh-cn.js
            zh.js
        plugins
            a11yhelp
                dialogs
                    a11yhelp.js
                    lang
                        _translationstatus.txt
                        af.js
                        ar.js
                        bg.js
                        ca.js
                        cs.js
                        cy.js
                        da.js
                        de.js
                        el.js
                        en-gb.js
                        en.js
                        eo.js
                        es.js
                        et.js
                        fa.js
                        fi.js
                        fo.js
                        fr-ca.js
                        fr.js
                        gl.js
                        gu.js
                        he.js
                        hi.js
                        hr.js
                        hu.js
                        id.js
                        it.js
                        ja.js
                        km.js
                        ko.js
                        ku.js
                        lt.js
                        lv.js
                        mk.js
                        mn.js
                        nb.js
                        nl.js
                        no.js
                        pl.js
                        pt-br.js
                        pt.js
                        ro.js
                        ru.js
                        si.js
                        sk.js
                        sl.js
                        sq.js
                        sr-latn.js
                        sr.js
                        sv.js
                        th.js
                        tr.js
                        tt.js
                        ug.js
                        uk.js
                        vi.js
                        zh-cn.js
                        zh.js
            about
                dialogs
                    about.js
                    hidpi
                        logo_ckeditor.png
                    logo_ckeditor.png
            clipboard
                dialogs
                    paste.js
            colordialog
                dialogs
                    colordialog.js
            dialog
                dialogDefinition.js
            div
                dialogs
                    div.js
            find
                dialogs
                    find.js
            flash
                dialogs
                    flash.js
                images
                    placeholder.png
            forms
                dialogs
                    button.js
                    checkbox.js
                    form.js
                    hiddenfield.js
                    radio.js
                    select.js
                    textarea.js
                    textfield.js
                images
                    hiddenfield.gif
            icons.png
            icons_hidpi.png
            iframe
                dialogs
                    iframe.js
                images
                    placeholder.png
            image
                dialogs
                    image.js
                images
                    noimage.png
            link
                dialogs
                    anchor.js
                    link.js
                images
                    anchor.png
                    hidpi
                        anchor.png
            liststyle
                dialogs
                    liststyle.js
            magicline
                images
                    hidpi
                        icon-rtl.png
                        icon.png
                    icon-rtl.png
                    icon.png
            pagebreak
                images
                    pagebreak.gif
            pastefromword
                filter
                    default.js
            preview
                preview.html
            scayt
                LICENSE.md
                README.md
                dialogs
                    options.js
                    toolbar.css
            showblocks
                images
                    block_address.png
                    block_blockquote.png
                    block_div.png
                    block_h1.png
                    block_h2.png
                    block_h3.png
                    block_h4.png
                    block_h5.png
                    block_h6.png
                    block_p.png
                    block_pre.png
            smiley
                dialogs
                    smiley.js
                images
                    angel_smile.gif
                    angel_smile.png
                    angry_smile.gif
                    angry_smile.png
                    broken_heart.gif
                    broken_heart.png
                    confused_smile.gif
                    confused_smile.png
                    cry_smile.gif
                    cry_smile.png
                    devil_smile.gif
                    devil_smile.png
                    embaressed_smile.gif
                    embarrassed_smile.gif
                    embarrassed_smile.png
                    envelope.gif
                    envelope.png
                    heart.gif
                    heart.png
                    kiss.gif
                    kiss.png
                    lightbulb.gif
                    lightbulb.png
                    omg_smile.gif
                    omg_smile.png
                    regular_smile.gif
                    regular_smile.png
                    sad_smile.gif
                    sad_smile.png
                    shades_smile.gif
                    shades_smile.png
                    teeth_smile.gif
                    teeth_smile.png
                    thumbs_down.gif
                    thumbs_down.png
                    thumbs_up.gif
                    thumbs_up.png
                    tongue_smile.gif
                    tongue_smile.png
                    tounge_smile.gif
                    whatchutalkingabout_smile.gif
                    whatchutalkingabout_smile.png
                    wink_smile.gif
                    wink_smile.png
            specialchar
                dialogs
                    lang
                        _translationstatus.txt
                        af.js
                        ar.js
                        bg.js
                        ca.js
                        cs.js
                        cy.js
                        da.js
                        de.js
                        el.js
                        en-gb.js
                        en.js
                        eo.js
                        es.js
                        et.js
                        fa.js
                        fi.js
                        fr-ca.js
                        fr.js
                        gl.js
                        he.js
                        hr.js
                        hu.js
                        id.js
                        it.js
                        ja.js
                        km.js
                        ko.js
                        ku.js
                        lt.js
                        lv.js
                        nb.js
                        nl.js
                        no.js
                        pl.js
                        pt-br.js
                        pt.js
                        ru.js
                        si.js
                        sk.js
                        sl.js
                        sq.js
                        sv.js
                        th.js
                        tr.js
                        tt.js
                        ug.js
                        uk.js
                        vi.js
                        zh-cn.js
                        zh.js
                    specialchar.js
            strinsert
                plugin.js
            table
                dialogs
                    table.js
            tabletools
                dialogs
                    tableCell.js
            templates
                dialogs
                    templates.css
                    templates.js
                templates
                    default.js
                    images
                        template1.gif
                        template2.gif
                        template3.gif
            wsc
                LICENSE.md
                README.md
                dialogs
                    ciframe.html
                    tmpFrameset.html
                    wsc.css
                    wsc.js
                    wsc_ie.js
        samples
            css
                samples.css
            img
                github-top.png
                header-bg.png
                header-separator.png
                logo.png
                navigation-tip.png
            index.html
            js
                sample.js
                sf.js
            old
                ajax.html
                api.html
                appendto.html
                assets
                    inlineall
                        logo.png
                    outputxhtml
                        outputxhtml.css
                    posteddata.php
                    sample.jpg
                    uilanguages
                        languages.js
                datafiltering.html
                dialog
                    assets
                        my_dialog.js
                    dialog.html
                divreplace.html
                enterkey
                    enterkey.html
                htmlwriter
                    assets
                        outputforflash
                            outputforflash.fla
                            outputforflash.swf
                            swfobject.js
                    outputforflash.html
                    outputhtml.html
                index.html
                inlineall.html
                inlinebycode.html
                inlinetextarea.html
                jquery.html
                magicline
                    magicline.html
                readonly.html
                replacebyclass.html
                replacebycode.html
                sample.css
                sample.js
                sample_posteddata.php
                tabindex.html
                toolbar
                    toolbar.html
                uicolor.html
                uilanguages.html
                wysiwygarea
                    fullpage.html
                xhtmlstyle.html
            toolbarconfigurator
                css
                    fontello.css
                font
                    LICENSE.txt
                    config.json
                    fontello.eot
                    fontello.svg
                    fontello.ttf
                    fontello.woff
                index.html
                js
                    abstracttoolbarmodifier.js
                    fulltoolbareditor.js
                    toolbarmodifier.js
                    toolbartextmodifier.js
                lib
                    codemirror
                        LICENSE
                        codemirror.css
                        codemirror.js
                        javascript.js
                        neo.css
                        show-hint.css
                        show-hint.js
        skins
            moono
                dialog.css
                dialog_ie.css
                dialog_ie7.css
                dialog_ie8.css
                dialog_iequirks.css
                editor.css
                editor_gecko.css
                editor_ie.css
                editor_ie7.css
                editor_ie8.css
                editor_iequirks.css
                icons.png
                icons_hidpi.png
                images
                    arrow.png
                    close.png
                    hidpi
                        close.png
                        lock-open.png
                        lock.png
                        refresh.png
                    lock-open.png
                    lock.png
                    refresh.png
                    spinner.gif
                readme.md
            office2013
                dialog.css
                editor.css
                icons.png
                icons_hidpi.png
                images
                    arrow.png
                    close.png
                    hidpi
                        close.png
                        lock-open.png
                        lock.png
                        refresh.png
                    lock-open.png
                    lock.png
                    refresh.png
                skin.js
        styles.js
    crop
        Canvas.php
        Coordinate.php
        Exception.php
        Font
            GDF.php
            PS.php
            TTF.php
        Image.php
        Mapper
            BMP.php
            GD.php
            GD2.php
            GIF.php
            JPEG.php
            PNG.php
            TGA.php
        MapperFactory.php
        Operation
            AddNoise.php
            ApplyConvolution.php
            ApplyFilter.php
            ApplyMask.php
            AsGrayscale.php
            AsNegative.php
            AutoCrop.php
            CopyChannelsPalette.php
            CopyChannelsTrueColor.php
            CorrectGamma.php
            Crop.php
            Flip.php
            GetMask.php
            Merge.php
            Mirror.php
            Resize.php
            ResizeCanvas.php
            Rotate.php
            RoundCorners.php
            Unsharp.php
        OperationFactory.php
        PaletteImage.php
        README
        TrueColorImage.php
        VERSION
        WideImage.php
        gpl.txt
        lgpl.txt
        vendor
            de77
                BMP.php
                TGA.php
    datetimepicker-master
        .gitignore
        MIT-LICENSE.txt
        README.md
        bower.json
        datetimepicker.jquery.json
        index.html
        jquery.datetimepicker.css
        jquery.datetimepicker.js
        jquery.js
        package.json
        screen
            1.png
            2.png
            3.1.png
            3.png
            4.png
            5.png
            6.png
    delete.png
    edit.png
    emailadd.png
    emailedit.png
    export.png
    filemanager
        LICENSE.TXT
        README.md
        changelog.txt
        filemanager
            ajax_calls.php
            config
                .htaccess
                config.php
            css
                style.css
            dialog.php
            execute.php
            force_download.php
            img
                clipboard_apply.png
                clipboard_clear.png
                copy.png
                cut.png
                date.png
                dimension.png
                down.png
                download.png
                duplicate.png
                edit_img.png
                file_edit.png
                glyphicons-halflings-white.png
                glyphicons-halflings.png
                ico
                    ac3.jpg
                    accdb.jpg
                    ade.jpg
                    adp.jpg
                    ai.jpg
                    aiff.jpg
                    avi.jpg
                    bmp.jpg
                    css.jpg
                    csv.jpg
                    default.jpg
                    dmg.jpg
                    doc.jpg
                    docx.jpg
                    favicon.ico
                    fla.jpg
                    flv.jpg
                    folder.png
                    folder_back.png
                    gif.jpg
                    gz.jpg
                    html.jpg
                    iso.jpg
                    jpeg.jpg
                    jpg.jpg
                    log.jpg
                    m4a.jpg
                    mdb.jpg
                    mid.jpg
                    mov.jpg
                    mp3.jpg
                    mp4.jpg
                    mpeg.jpg
                    mpg.jpg
                    odb.jpg
                    odf.jpg
                    odg.jpg
                    odp.jpg
                    ods.jpg
                    odt.jpg
                    ogg.jpg
                    otg.jpg
                    otp.jpg
                    ots.jpg
                    ott.jpg
                    pdf.jpg
                    png.jpg
                    ppt.jpg
                    pptx.jpg
                    psd.jpg
                    rar.jpg
                    rtf.jpg
                    sql.jpg
                    svg.jpg
                    tar.jpg
                    tiff.jpg
                    txt.jpg
                    wav.jpg
                    webm.jpg
                    wma.jpg
                    xhtml.jpg
                    xls.jpg
                    xlsx.jpg
                    xml.jpg
                    zip.jpg
                ico_dark
                    ac3.jpg
                    accdb.jpg
                    ade.jpg
                    adp.jpg
                    ai.jpg
                    aiff.jpg
                    avi.jpg
                    bmp.jpg
                    css.jpg
                    csv.jpg
                    default.jpg
                    dmg.jpg
                    doc.jpg
                    docx.jpg
                    favicon.ico
                    fla.jpg
                    flv.jpg
                    folder.png
                    folder_back.png
                    gif.jpg
                    gz.jpg
                    html.jpg
                    iso.jpg
                    jpeg.jpg
                    jpg.jpg
                    log.jpg
                    m4a.jpg
                    mdb.jpg
                    mid.jpg
                    mov.jpg
                    mp3.jpg
                    mp4.jpg
                    mpeg.jpg
                    mpg.jpg
                    odb.jpg
                    odf.jpg
                    odg.jpg
                    odp.jpg
                    ods.jpg
                    odt.jpg
                    ogg.jpg
                    otg.jpg
                    otp.jpg
                    ots.jpg
                    ott.jpg
                    pdf.jpg
                    png.jpg
                    ppt.jpg
                    pptx.jpg
                    psd.jpg
                    rar.jpg
                    rtf.jpg
                    sql.jpg
                    svg.jpg
                    tar.jpg
                    tiff.jpg
                    txt.jpg
                    wav.jpg
                    webm.jpg
                    wma.jpg
                    xhtml.jpg
                    xls.jpg
                    xlsx.jpg
                    xml.jpg
                    zip.jpg
                info.png
                key.png
                label.png
                loading.gif
                logo.png
                preview.png
                processing.gif
                rename.png
                size.png
                sort.png
                storing_animation.gif
                up.png
                upload.png
                url.png
                zip.png
            include
                Response.php
                mime_type_lib.php
                php_image_magician.php
                utils.php
            js
                ViewerJS
                    AGPL-3.0.txt
                    ODFViewerPlugin.css
                    ODFViewerPlugin.js
                    PDFViewerPlugin.css
                    PDFViewerPlugin.js
                    PluginLoader.js
                    compatibility.js
                    example.local.css
                    images
                        kogmbh.png
                        nlnet.png
                        texture.png
                        toolbarButton-download.png
                        toolbarButton-fullscreen.png
                        toolbarButton-menuArrows.png
                        toolbarButton-pageDown.png
                        toolbarButton-pageUp.png
                        toolbarButton-presentation.png
                        toolbarButton-zoomIn.png
                        toolbarButton-zoomOut.png
                    index.html
                    local.css
                    pdf.js
                    pdf.worker.js
                    pdfjsversion.js
                    text_layer_builder.js
                    ui_utils.js
                    viewer.css
                    viewer.js
                    webodf.js
                ZeroClipboard.swf
                include.js
                jPlayer
                    MIT-LICENSE.txt
                    README.md
                    actionscript
                        Jplayer.as
                        Jplayer.fla
                        happyworm
                            jPlayer
                                ConnectManager.as
                                JplayerEvent.as
                                JplayerMp3.as
                                JplayerMp4.as
                                JplayerRtmp.as
                                JplayerStatus.as
                                TraceOut.as
                    add-on
                        jplayer.playlist.js
                        jquery.jplayer.inspector.js
                    jplayer.jquery.json
                    jquery.jplayer
                        Jplayer.swf
                        jquery.jplayer.js
                    package.json
                    popcorn
                        player
                            popcorn.jplayer.js
                    skin
                        blue.monday
                            jplayer.blue.monday.css
                            jplayer.blue.monday.jpg
                            jplayer.blue.monday.seeking.gif
                            jplayer.blue.monday.video.play.png
                            skin.handlebars
                        pink.flag
                            jplayer.pink.flag.css
                            jplayer.pink.flag.jpg
                            jplayer.pink.flag.seeking.gif
                            jplayer.pink.flag.video.play.png
                modernizr.custom.js
                plugins.js
            lang
                az_AZ.php
                bg_BG.php
                ca.php
                cs.php
                da.php
                de.php
                el_GR.php
                en_EN.php
                es.php
                fa.php
                fr_FR.php
                he_IL.php
                hr.php
                hu_HU.php
                id.php
                it.php
                ja.php
                languages.php
                lt.php
                mn_MN.php
                nb_NO.php
                nl.php
                pl.php
                pt_BR.php
                pt_PT.php
                ru.php
                sk.php
                sl.php
                sv_SE.php
                tr_TR.php
                uk_UA.php
                vi.php
                zh_CN.php
            plugin.min.js
            upload.php
            uploader
                index.php
                jupload.php
                success.jpg
                success.php
                wjhk.jupload.jar
        source
            Chrysanthemum.jpg
            source.txt
        thumbs
            Chrysanthemum.jpg
            thumbs.txt
        tinymce
            plugins
                responsivefilemanager
                    img
                        insertfile.gif
                    plugin.min.js
    habout.png
    haccount.png
    haccountedit.png
    hcopyright.png
    hdraft.png
    heditmessage.png
    hedittime.png
    hemailadd.png
    hemailedit.png
    hexclusion.png
    hexport.png
    hgroup.png
    hgroupedit.png
    himport.png
    hlogin.png
    hlogs.png
    hmainpage.png
    hmessage.png
    hnewmessage.png
    hoptions.png
    hpassword.png
    hprofile.png
    hreport.png
    hsend.png
    hsign.png
    hsignedit.png
    hstats.png
    htime.png
    huseradd.png
    husers.png
    hviewgroup.png
    import.png
    index.html
    jqsimplemenu
        css
            jqsimplemenu.css
        images
            darrow.png
            rarrow.png
        index.html
        js
            jqsimplemenu.js
            jquery-1.4.4.min.js
    jquery-autocomplete
        changelog.txt
        demo
            bg.gif
            emails.php
            emails.phps
            images
                Amsterdam Van-Gogh Museum.jpg
                Amsterdam.jpg
                Antwerpen Rubenshaus.jpg
                Antwerpen.jpg
                Appenzell.jpg
                Arnhem Historisches Museum.jpg
                Bled.jpg
                Bled_Die Burg von Bled.jpg
                Bogojina_Die Pfarrkirche.jpg
                BolognaBasilicadiSanPetronio.jpg
                BolognaFontanadelNettuno.jpg
                BolognaPiazzaMaggiore.jpg
                Bolsward Martinikerk.jpg
                Bolsward Stadhuis.jpg
                Bolsward.jpg
                BordeauxND.jpg
                BordeauxPlaceB.jpg
                BotanischerGartenZuerich.jpg
                Bouillon.jpg
                Gent Hotel de Ville2.jpg
                Gent.jpg
                GenuaStrand.jpg
                GenuabeiNacht.jpg
                Giessbachfaelle Brienz.jpg
                Giethoorn.jpg
                Gnesen.jpg
                Gornij Grad_KATHEDRALE.jpg
                Gossensass.jpg
                Grad_Burg Grad2.jpg
                GrandDixence.jpg
                GrenoblePanorama.jpg
                Groningen.jpg
                GrottenvonReclere.jpg
                Guebwiller.jpg
                Kamnik_Die Franziskaner Bibliothek.jpg
                Karlsbad Muehlbrunnkolonnade.jpg
                Kazimierz.jpg
                KirchbergAltesRathaus1.jpg
                KlagenfurtDom.jpg
                KleineMeerjungfreu.jpg
                LazienkiparkWarschau.jpg
                LeHavreHafen.jpg
                LeMans.jpg
                Lednice.jpg
                Leeuwarden Fries Museum.jpg
                Leeuwarden.jpg
                Lelystad.jpg
                Lemmer.jpg
                Leper Halles aux draps.jpg
                Leuven Museum fuer Kirchenkunst.jpg
                Leuven.jpg
                Luxemburg.jpg
                LuzernAltstadt.jpg
                LuzernPicassoMuseum.jpg
                Lyon.jpg
                Maastricht Onze Lieve Vrou...jpg
                Maastricht St Servaasbasiliek.jpg
                Maastricht Walmuur.jpg
                Maastricht.jpg
                MagiatalMaggia.jpg
                Mailand3.jpg
                Metlika_Bela Krajina Museum.jpg
                MilanoCastelloSforzesco.jpg
                MilanoDom.jpg
                MilazzoBurg.jpg
                Novo Mesto_Das Museum.jpg
                ObervellachBurgFalkenstein.jpg
                OdenseeAndersen.jpg
                Olimje_Kirche und Apotheke in Olimje.jpg
                Olomouc.jpg
                OlympischesMuseumLausanne.jpg
                OrleansMaisonJeannedArc.jpg
                OrleansParcFloraldelaSource.jpg
                OstiaAntica.jpg
                Ostrow Tumski.jpg
                PoertschachSchlossLeonstain.jpg
                Portoroz.jpg
                Posen.jpg
                Postojna.jpg
                Prag Altstaedter Ring.jpg
                Prag Waldsteinpalais.jpg
                RouenNotreDame.jpg
                Salzbergwerk Bex.jpg
                SalzbergwerkWieliczka.jpg
                SalzburgFestungHohensalzburg.jpg
                SalzburgResidenz.jpg
                WienMuseumsQuartier.jpg
                WienMusikverein.jpg
                WienRiesenrad.jpg
                WienRingstrasse.jpg
            images.php
            index.html
            indicator.gif
            json.html
            localdata.js
            main.css
            search.php
            search.phps
        jquery.autocomplete.css
        jquery.autocomplete.js
        jquery.autocomplete.min.js
        jquery.autocomplete.pack.js
        lib
            jquery.ajaxQueue.js
            jquery.bgiframe.min.js
            jquery.js
            thickbox-compressed.js
            thickbox.css
        todo
    jquery-ui
        external
            jquery
                jquery.js
        images
            ui-bg_diagonals-thick_18_b81900_40x40.png
            ui-bg_diagonals-thick_20_666666_40x40.png
            ui-bg_flat_0_aaaaaa_40x100.png
            ui-bg_flat_10_000000_40x100.png
            ui-bg_flat_55_fbec88_40x100.png
            ui-bg_flat_75_ffffff_40x100.png
            ui-bg_glass_100_f6f6f6_1x400.png
            ui-bg_glass_100_fdf5ce_1x400.png
            ui-bg_glass_55_fbf9ee_1x400.png
            ui-bg_glass_65_ffffff_1x400.png
            ui-bg_glass_75_d0e5f5_1x400.png
            ui-bg_glass_75_dadada_1x400.png
            ui-bg_glass_75_e6e6e6_1x400.png
            ui-bg_glass_85_dfeffc_1x400.png
            ui-bg_glass_95_fef1ec_1x400.png
            ui-bg_gloss-wave_35_f6a828_500x100.png
            ui-bg_gloss-wave_55_5c9ccc_500x100.png
            ui-bg_highlight-soft_100_eeeeee_1x100.png
            ui-bg_highlight-soft_75_cccccc_1x100.png
            ui-bg_highlight-soft_75_ffe45c_1x100.png
            ui-bg_inset-hard_100_f5f8f9_1x100.png
            ui-bg_inset-hard_100_fcfdfd_1x100.png
            ui-icons_217bc0_256x240.png
            ui-icons_222222_256x240.png
            ui-icons_228ef1_256x240.png
            ui-icons_2e83ff_256x240.png
            ui-icons_454545_256x240.png
            ui-icons_469bdd_256x240.png
            ui-icons_6da8d5_256x240.png
            ui-icons_888888_256x240.png
            ui-icons_cd0a0a_256x240.png
            ui-icons_d8e7f3_256x240.png
            ui-icons_ef8c08_256x240.png
            ui-icons_f9bd01_256x240.png
            ui-icons_ffd27a_256x240.png
            ui-icons_ffffff_256x240.png
        index.html
        jquery-ui.css
        jquery-ui.js
        jquery-ui.min.css
        jquery-ui.min.js
        jquery-ui.structure.css
        jquery-ui.structure.min.css
        jquery-ui.theme.css
        jquery-ui.theme.min.css
    jquery-ui-sliderAccess.js
    jquery-ui-timepicker-addon.css
    jquery-ui-timepicker-addon.js
    jquery-ui.css
    jquery-ui.min.js
    jquery.min.js
    jscolor
        arrow.gif
        cross.gif
        demo.html
        hs.png
        hv.png
        jscolor.js
    mailIcon.ico
    mailIcon.png
    nodelete.png
    notlogin.png
    report.png
    stats.png
    style.css
    time.png
    user.png
    useradd.png
    view
        bg.png
        bgtop.png
        top1.png
        top2.png
        top3.png
    viewgroup.png
smtpcheck.php
system
    .htaccess
    core
        Benchmark.php
        CodeIgniter.php
        Common.php
        Config.php
        Controller.php
        Exceptions.php
        Hooks.php
        Input.php
        Lang.php
        Loader.php
        Log.php
        Model.php
        Output.php
        Router.php
        Security.php
        URI.php
        Utf8.php
        compat
            hash.php
            index.html
            mbstring.php
            password.php
            standard.php
        index.html
    database
        DB.php
        DB_cache.php
        DB_driver.php
        DB_forge.php
        DB_query_builder.php
        DB_result.php
        DB_utility.php
        drivers
            cubrid
                cubrid_driver.php
                cubrid_forge.php
                cubrid_result.php
                cubrid_utility.php
                index.html
            ibase
                ibase_driver.php
                ibase_forge.php
                ibase_result.php
                ibase_utility.php
                index.html
            index.html
            mssql
                index.html
                mssql_driver.php
                mssql_forge.php
                mssql_result.php
                mssql_utility.php
            mysql
                index.html
                mysql_driver.php
                mysql_forge.php
                mysql_result.php
                mysql_utility.php
            mysqli
                index.html
                mysqli_driver.php
                mysqli_forge.php
                mysqli_result.php
                mysqli_utility.php
            oci8
                index.html
                oci8_driver.php
                oci8_forge.php
                oci8_result.php
                oci8_utility.php
            odbc
                index.html
                odbc_driver.php
                odbc_forge.php
                odbc_result.php
                odbc_utility.php
            pdo
                index.html
                pdo_driver.php
                pdo_forge.php
                pdo_result.php
                pdo_utility.php
                subdrivers
                    index.html
                    pdo_4d_driver.php
                    pdo_4d_forge.php
                    pdo_cubrid_driver.php
                    pdo_cubrid_forge.php
                    pdo_dblib_driver.php
                    pdo_dblib_forge.php
                    pdo_firebird_driver.php
                    pdo_firebird_forge.php
                    pdo_ibm_driver.php
                    pdo_ibm_forge.php
                    pdo_informix_driver.php
                    pdo_informix_forge.php
                    pdo_mysql_driver.php
                    pdo_mysql_forge.php
                    pdo_oci_driver.php
                    pdo_oci_forge.php
                    pdo_odbc_driver.php
                    pdo_odbc_forge.php
                    pdo_pgsql_driver.php
                    pdo_pgsql_forge.php
                    pdo_sqlite_driver.php
                    pdo_sqlite_forge.php
                    pdo_sqlsrv_driver.php
                    pdo_sqlsrv_forge.php
            postgre
                index.html
                postgre_driver.php
                postgre_forge.php
                postgre_result.php
                postgre_utility.php
            sqlite
                index.html
                sqlite_driver.php
                sqlite_forge.php
                sqlite_result.php
                sqlite_utility.php
            sqlite3
                index.html
                sqlite3_driver.php
                sqlite3_forge.php
                sqlite3_result.php
                sqlite3_utility.php
            sqlsrv
                index.html
                sqlsrv_driver.php
                sqlsrv_forge.php
                sqlsrv_result.php
                sqlsrv_utility.php
        index.html
    fonts
        index.html
        texb.ttf
    helpers
        array_helper.php
        captcha_helper.php
        cookie_helper.php
        date_helper.php
        directory_helper.php
        download_helper.php
        email_helper.php
        file_helper.php
        form_helper.php
        html_helper.php
        index.html
        inflector_helper.php
        language_helper.php
        number_helper.php
        path_helper.php
        security_helper.php
        smiley_helper.php
        string_helper.php
        text_helper.php
        typography_helper.php
        url_helper.php
        xml_helper.php
    index.html
    language
        english
            calendar_lang.php
            date_lang.php
            db_lang.php
            email_lang.php
            form_validation_lang.php
            ftp_lang.php
            imglib_lang.php
            index.html
            migration_lang.php
            number_lang.php
            pagination_lang.php
            profiler_lang.php
            unit_test_lang.php
            upload_lang.php
        index.html
    libraries
        Cache
            Cache.php
            drivers
                Cache_apc.php
                Cache_dummy.php
                Cache_file.php
                Cache_memcached.php
                Cache_redis.php
                Cache_wincache.php
                index.html
            index.html
        Calendar.php
        Cart.php
        Driver.php
        Email.php
        Encrypt.php
        Encryption.php
        Form_validation.php
        Ftp.php
        Image_lib.php
        Javascript
            Jquery.php
            index.html
        Javascript.php
        Migration.php
        Pagination.php
        Parser.php
        Profiler.php
        Session
            Session.php
            SessionHandlerInterface.php
            Session_driver.php
            drivers
                Session_database_driver.php
                Session_files_driver.php
                Session_memcached_driver.php
                Session_redis_driver.php
                index.html
            index.html
        Table.php
        Trackback.php
        Typography.php
        Unit_test.php
        Upload.php
        User_agent.php
        Xmlrpc.php
        Xmlrpcs.php
        Zip.php
        index.html
thumbs
    sys.txt
uploads
    sys.txt
<?php
# ========================================================================#
#
#  This work is licensed under the Creative Commons Attribution 3.0 Unported
#  License. To view a copy of this license,
#  visit http://creativecommons.org/licenses/by/3.0/ or send a letter to
#  Creative Commons, 444 Castro Street, Suite 900, Mountain View, California,
#  94041, USA.
#
#  All rights reserved.
#
#  Author:    Jarrod Oberto
#  Version:   1.5.1
#  Date:      10-05-11
#  Purpose:   Provide tools for image manipulation using GD
#  Param In:  See functions.
#  Param Out: Produces a resized image
#  Requires : Requires PHP GD library.
#  Usage Example:
#                     include("lib/php_image_magician.php");
#                     $magicianObj = new resize('images/car.jpg');
#                     $magicianObj -> resizeImage(150, 100, 0);
#                     $magicianObj -> saveImage('images/car_small.jpg', 100);
#
#        - See end of doc for more examples -
#
#  Supported file types include: jpg, png, gif, bmp, psd (read)
#
#
#
#  The following functions are taken from phpThumb() [available from
#    http://phpthumb.sourceforge.net], and are used with written permission
#  from James Heinrich.
#    - GD2BMPstring
#      - GetPixelColor
#      - LittleEndian2String
#
#  The following functions are from Marc Hibbins and are used with written
#  permission (are also under the Attribution-ShareAlike
#  [http://creativecommons.org/licenses/by-sa/3.0/] license.
#    -
#
#  PhpPsdReader is used with written permission from Tim de Koning.
#  [http://www.kingsquare.nl/phppsdreader]
#
#
#
#  Modificatoin history
#  Date      Initials  Ver Description
#  10-05-11  J.C.O   0.0 Initial build
#  01-06-11  J.C.O   0.1.1   * Added reflections
#              * Added Rounded corners
#              * You can now use PNG interlacing
#              * Added shadow
#              * Added caption box
#              * Added vintage filter
#              * Added dynamic image resizing (resize on the fly)
#              * minor bug fixes
#  05-06-11  J.C.O   0.1.1.1 * Fixed undefined variables
#  17-06-11  J.C.O   0.1.2   * Added image_batch_class.php class
#              * Minor bug fixes
#  26-07-11  J.C.O   0.1.4 * Added support for external images
#              * Can now set the crop poisition
#  03-08-11  J.C.O   0.1.5 * Added reset() method to reset resource to
#                original input file.
#              * Added method addTextToCaptionBox() to
#                simplify adding text to a caption box.
#              * Added experimental writeIPTC. (not finished)
#              * Added experimental readIPTC. (not finished)
#  11-08-11  J.C.O     * Added initial border presets.
#  30-08-11  J.C.O     * Added 'auto' crop option to crop portrait
#                images near the top.
#  08-09-11  J.C.O     * Added cropImage() method to allow standalone
#                cropping.
#  17-09-11  J.C.O     * Added setCropFromTop() set method - set the
#                percentage to crop from the top when using
#                crop 'auto' option.
#              * Added setTransparency() set method - allows you
#                to turn transparency off (like when saving
#                as a jpg).
#              * Added setFillColor() set method - set the
#                background color to use instead of transparency.
#  05-11-11  J.C.O   0.1.5.1 * Fixed interlacing option
#  0-07-12  J.C.O   1.0
#
#  Known issues & Limitations:
# -------------------------------
#  Not so much an issue, the image is destroyed on the deconstruct rather than
#  when we have finished with it. The reason for this is that we don't know
#  when we're finished with it as you can both save the image and display
#  it directly to the screen (imagedestroy($this->imageResized))
#
#  Opening BMP files is slow. A test with 884 bmp files processed in a loop
#  takes forever - over 5 min. This test inlcuded opening the file, then
#  getting and displaying its width and height.
#
#  $forceStretch:
# -------------------------------
#  On by default.
#  $forceStretch can be disabled by calling method setForceStretch with false
#  parameter. If disabled, if an images original size is smaller than the size
#  specified by the user, the original size will be used. This is useful when
#  dealing with small images.
#
#  If enabled, images smaller than the size specified will be stretched to
#  that size.
#
#  Tips:
# -------------------------------
#  * If you're resizing a transparent png and saving it as a jpg, set
#  $keepTransparency to false with: $magicianObj->setTransparency(false);
#
#  FEATURES:
#    * EASY TO USE
#    * BMP SUPPORT (read & write)
#    * PSD (photoshop) support (read)
#    * RESIZE IMAGES
#      - Preserve transparency (png, gif)
#      - Apply sharpening (jpg) (requires PHP >= 5.1.0)
#      - Set image quality (jpg, png)
#      - Resize modes:
#        - exact size
#        - resize by width (auto height)
#        - resize by height (auto width)
#        - auto (automatically determine the best of the above modes to use)
#        - crop - resize as best as it can then crop the rest
#      - Force stretching of smaller images (upscale)
#    * APPLY FILTERS
#      - Convert to grey scale
#      - Convert to black and white
#      - Convert to sepia
#      - Convert to negative
#    * ROTATE IMAGES
#      - Rotate using predefined "left", "right", or "180"; or any custom degree amount
#    * EXTRACT EXIF DATA (requires exif module)
#      - make
#      - model
#      - date
#      - exposure
#      - aperture
#      - f-stop
#      - iso
#      - focal length
#      - exposure program
#      - metering mode
#      - flash status
#      - creator
#      - copyright
#    * ADD WATERMARK
#      - Specify exact x, y placement
#      - Or, specify using one of the 9 pre-defined placements such as "tl"
#        (for top left), "m" (for middle), "br" (for bottom right)
#        - also specify padding from edge amount (optional).
#      - Set opacity of watermark (png).
#    * ADD BORDER
#    * USE HEX WHEN SPECIFYING COLORS (eg: #ffffff)
#    * SAVE IMAGE OR OUTPUT TO SCREEN
#
#
# ========================================================================#


class imageLib {

	private   $fileName;
	private   $image;
	protected $imageResized;
	private   $widthOriginal;     # Always be the original width
	private   $heightOriginal;
	private   $width;         # Current width (width after resize)
	private   $height;
	private   $imageSize;
	private   $fileExtension;

	private $debug      = true;
	private $errorArray = array();

	private $forceStretch        = true;
	private $aggresiveSharpening = false;

	private $transparentArray = array( '.png', '.gif' );
	private $keepTransparency = true;
	private $fillColorArray   = array( 'r' => 255, 'g' => 255, 'b' => 255 );

	private $sharpenArray = array( 'jpg' );

	private $psdReaderPath;
	private $filterOverlayPath;

	private $isInterlace;

	private $captionBoxPositionArray = array();

	private $fontDir = 'fonts';

	private $cropFromTopPercent = 10;


## --------------------------------------------------------

	function __construct($fileName)
		# Author:     Jarrod Oberto
		# Date:     27-02-08
		# Purpose:    Constructor
		# Param in:   $fileName: File name and path.
		# Param out:  n/a
		# Reference:
		# Notes:
		#
	{
		if ( ! $this->testGDInstalled())
		{
			if ($this->debug)
			{
				throw new Exception('The GD Library is not installed.');
			}
			else
			{
				throw new Exception();
			}
		};

		$this->initialise();

		// *** Save the image file name. Only store this incase you want to display it
		$this->fileName = $fileName;
		$this->fileExtension = fix_strtolower(strrchr($fileName, '.'));

		// *** Open up the file
		$this->image = $this->openImage($fileName);


		// *** Assign here so we don't modify the original
		$this->imageResized = $this->image;

		// *** If file is an image
		if ($this->testIsImage($this->image))
		{
			// *** Get width and height
			$this->width = imagesx($this->image);
			$this->widthOriginal = imagesx($this->image);
			$this->height = imagesy($this->image);
			$this->heightOriginal = imagesy($this->image);


			/*  Added 15-09-08
         *  Get the filesize using this build in method.
         *  Stores an array of size
         *
         *  $this->imageSize[1] = width
         *  $this->imageSize[2] = height
         *  $this->imageSize[3] = width x height
         *
         */
			$this->imageSize = getimagesize($this->fileName);

		}
		else
		{
			$this->errorArray[] = 'File is not an image';
		}
	}

## --------------------------------------------------------

	private function initialise()
	{

		$this->psdReaderPath = dirname(__FILE__) . '/classPhpPsdReader.php';
		$this->filterOverlayPath = dirname(__FILE__) . '/filters';

		// *** Set if image should be interlaced or not.
		$this->isInterlace = false;
	}


	/*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-**-*-*-*-*-*-*-*-*-*-*-*-*-*-
  Resize
*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-**-*-*-*-*-*-*-*-*-*-*-*-*-*/


	public function resizeImage($newWidth, $newHeight, $option = 0, $sharpen = false, $autoRotate = false)
		# Author:     Jarrod Oberto
		# Date:       27-02-08
		# Purpose:    Resizes the image
		# Param in:   $newWidth:
		#             $newHeight:
		#             $option:     0 / exact = defined size;
		#                          1 / portrait = keep aspect set height;
		#                          2 / landscape = keep aspect set width;
		#                          3 / auto = auto;
		#                          4 / crop= resize and crop;
		#
		#         $option can also be an array containing options for
		#         cropping. E.G., array('crop', 'r')
		#
		#         This array only applies to 'crop' and the 'r' refers to
		#         "crop right". Other value include; tl, t, tr, l, m (default),
		#         r, bl, b, br, or you can specify your own co-ords (which
		#         isn't recommended.
		#
		#       $sharpen:    true: sharpen (jpg only);
		#                false: don't sharpen
		# Param out:  n/a
		# Reference:
		# Notes:      To clarify the $option input:
		#               0 = The exact height and width dimensions you set.
		#               1 = Whatever height is passed in will be the height that
		#                   is set. The width will be calculated and set automatically
		#                   to a the value that keeps the original aspect ratio.
		#               2 = The same but based on the width. We try make the image the
		#                  biggest size we can while stil fitting inside the box size
		#               3 = Depending whether the image is landscape or portrait, this
		#                   will automatically determine whether to resize via
		#                   dimension 1,2 or 0
		#               4 = Will resize and then crop the image for best fit
		#
		#       forceStretch can be applied to options 1,2,3 and 4
		#
	{

		// *** We can pass in an array of options to change the crop position
		$cropPos = 'm';
		if (is_array($option) && fix_strtolower($option[0]) == 'crop')
		{
			$cropPos = $option[1];         # get the crop option
		}
		else
		{
			if (strpos($option, '-') !== false)
			{
				// *** Or pass in a hyphen seperated option
				$optionPiecesArray = explode('-', $option);
				$cropPos = end($optionPiecesArray);
			}
		}

		// *** Check the option is valid
		$option = $this->prepOption($option);

		// *** Make sure the file passed in is valid
		if ( ! $this->image)
		{
			if ($this->debug)
			{
				throw new Exception('file ' . $this->getFileName() . ' is missing or invalid');
			}
			else
			{
				throw new Exception();
			}
		};

		// *** Get optimal width and height - based on $option
		$dimensionsArray = $this->getDimensions($newWidth, $newHeight, $option);

		$optimalWidth = $dimensionsArray['optimalWidth'];
		$optimalHeight = $dimensionsArray['optimalHeight'];

		// *** Resample - create image canvas of x, y size
		$this->imageResized = imagecreatetruecolor($optimalWidth, $optimalHeight);
		$this->keepTransparancy($optimalWidth, $optimalHeight, $this->imageResized);
		imagecopyresampled($this->imageResized, $this->image, 0, 0, 0, 0, $optimalWidth, $optimalHeight, $this->width, $this->height);


		// *** If '4', then crop too
		if ($option == 4 || $option == 'crop')
		{

			if (($optimalWidth >= $newWidth && $optimalHeight >= $newHeight))
			{
				$this->crop($optimalWidth, $optimalHeight, $newWidth, $newHeight, $cropPos);
			}
		}

		// *** If Rotate.
		if ($autoRotate)
		{

			$exifData = $this->getExif(false);
			if (count($exifData) > 0)
			{

				switch ($exifData['orientation'])
				{
					case 8:
						$this->imageResized = imagerotate($this->imageResized, 90, 0);
						break;
					case 3:
						$this->imageResized = imagerotate($this->imageResized, 180, 0);
						break;
					case 6:
						$this->imageResized = imagerotate($this->imageResized, -90, 0);
						break;
				}
			}
		}

		// *** Sharpen image (if jpg and the user wishes to do so)
		if ($sharpen && in_array($this->fileExtension, $this->sharpenArray))
		{

			// *** Sharpen
			$this->sharpen();
		}
	}

## --------------------------------------------------------

	public function cropImage($newWidth, $newHeight, $cropPos = 'm')
		# Author:     Jarrod Oberto
		# Date:       08-09-11
		# Purpose:    Crops the image
		# Param in:   $newWidth: crop with
		#             $newHeight: crop height
		#       $cropPos: Can be any of the following:
		#             tl, t, tr, l, m, r, bl, b, br, auto
		#           Or:
		#             a custom position such as '30x50'
		# Param out:  n/a
		# Reference:
		# Notes:
		#
	{

		// *** Make sure the file passed in is valid
		if ( ! $this->image)
		{
			if ($this->debug)
			{
				throw new Exception('file ' . $this->getFileName() . ' is missing or invalid');
			}
			else
			{
				throw new Exception();
			}
		};

		$this->imageResized = $this->image;
		$this->crop($this->width, $this->height, $newWidth, $newHeight, $cropPos);

	}

## --------------------------------------------------------

	private function keepTransparancy($width, $height, $im)
		# Author:     Jarrod Oberto
		# Date:       08-04-11
		# Purpose:    Keep transparency for png and gif image
		# Param in:
		# Param out:  n/a
		# Reference:
		# Notes:
		#
	{
		// *** If PNG, perform some transparency retention actions (gif untested)
		if (in_array($this->fileExtension, $this->transparentArray) && $this->keepTransparency)
		{
			imagealphablending($im, false);
			imagesavealpha($im, true);
			$transparent = imagecolorallocatealpha($im, 255, 255, 255, 127);
			imagefilledrectangle($im, 0, 0, $width, $height, $transparent);
		}
		else
		{
			$color = imagecolorallocate($im, $this->fillColorArray['r'], $this->fillColorArray['g'], $this->fillColorArray['b']);
			imagefilledrectangle($im, 0, 0, $width, $height, $color);
		}
	}

## --------------------------------------------------------

	private function crop($optimalWidth, $optimalHeight, $newWidth, $newHeight, $cropPos)
		# Author:     Jarrod Oberto
		# Date:       15-09-08
		# Purpose:    Crops the image
		# Param in:   $newWidth:
		#             $newHeight:
		# Param out:  n/a
		# Reference:
		# Notes:
		#
	{

		// *** Get cropping co-ordinates
		$cropArray = $this->getCropPlacing($optimalWidth, $optimalHeight, $newWidth, $newHeight, $cropPos);
		$cropStartX = $cropArray['x'];
		$cropStartY = $cropArray['y'];

		// *** Crop this bad boy
		$crop = imagecreatetruecolor($newWidth, $newHeight);
		$this->keepTransparancy($optimalWidth, $optimalHeight, $crop);
		imagecopyresampled($crop, $this->imageResized, 0, 0, $cropStartX, $cropStartY, $newWidth, $newHeight, $newWidth, $newHeight);

		$this->imageResized = $crop;

		// *** Set new width and height to our variables
		$this->width = $newWidth;
		$this->height = $newHeight;

	}

## --------------------------------------------------------

	private function getCropPlacing($optimalWidth, $optimalHeight, $newWidth, $newHeight, $pos = 'm')
		#
		# Author:   Jarrod Oberto
		# Date:   July 11
		# Purpose:  Set the cropping area.
		# Params in:
		# Params out: (array) the crop x and y co-ordinates.
		# Notes:    When specifying the exact pixel crop position (eg 10x15), be
		#       very careful as it's easy to crop out of the image leaving
		#       black borders.
		#
	{
		$pos = fix_strtolower($pos);

		// *** If co-ords have been entered
		if (strstr($pos, 'x'))
		{
			$pos = str_replace(' ', '', $pos);

			$xyArray = explode('x', $pos);
			list($cropStartX, $cropStartY) = $xyArray;

		}
		else
		{

			switch ($pos)
			{
				case 'tl':
					$cropStartX = 0;
					$cropStartY = 0;
					break;

				case 't':
					$cropStartX = ($optimalWidth / 2) - ($newWidth / 2);
					$cropStartY = 0;
					break;

				case 'tr':
					$cropStartX = $optimalWidth - $newWidth;
					$cropStartY = 0;
					break;

				case 'l':
					$cropStartX = 0;
					$cropStartY = ($optimalHeight / 2) - ($newHeight / 2);
					break;

				case 'm':
					$cropStartX = ($optimalWidth / 2) - ($newWidth / 2);
					$cropStartY = ($optimalHeight / 2) - ($newHeight / 2);
					break;

				case 'r':
					$cropStartX = $optimalWidth - $newWidth;
					$cropStartY = ($optimalHeight / 2) - ($newHeight / 2);
					break;

				case 'bl':
					$cropStartX = 0;
					$cropStartY = $optimalHeight - $newHeight;
					break;

				case 'b':
					$cropStartX = ($optimalWidth / 2) - ($newWidth / 2);
					$cropStartY = $optimalHeight - $newHeight;
					break;

				case 'br':
					$cropStartX = $optimalWidth - $newWidth;
					$cropStartY = $optimalHeight - $newHeight;
					break;

				case 'auto':
					// *** If image is a portrait crop from top, not center. v1.5
					if ($optimalHeight > $optimalWidth)
					{
						$cropStartX = ($optimalWidth / 2) - ($newWidth / 2);
						$cropStartY = ($this->cropFromTopPercent / 100) * $optimalHeight;
					}
					else
					{

						// *** Else crop from the center
						$cropStartX = ($optimalWidth / 2) - ($newWidth / 2);
						$cropStartY = ($optimalHeight / 2) - ($newHeight / 2);
					}
					break;

				default:
					// *** Default to center
					$cropStartX = ($optimalWidth / 2) - ($newWidth / 2);
					$cropStartY = ($optimalHeight / 2) - ($newHeight / 2);
					break;
			}
		}

		return array( 'x' => $cropStartX, 'y' => $cropStartY );
	}

## --------------------------------------------------------

	private function getDimensions($newWidth, $newHeight, $option)
		# Author:     Jarrod Oberto
		# Date:       17-11-09
		# Purpose:    Get new image dimensions based on user specificaions
		# Param in:   $newWidth:
		#             $newHeight:
		# Param out:  Array of new width and height values
		# Reference:
		# Notes:    If $option = 3 then this function is call recursivly
		#
		#       To clarify the $option input:
		#               0 = The exact height and width dimensions you set.
		#               1 = Whatever height is passed in will be the height that
		#                   is set. The width will be calculated and set automatically
		#                   to a the value that keeps the original aspect ratio.
		#               2 = The same but based on the width.
		#               3 = Depending whether the image is landscape or portrait, this
		#                   will automatically determine whether to resize via
		#                   dimension 1,2 or 0.
		#               4 = Resize the image as much as possible, then crop the
		#         remainder.
	{

		switch (strval($option))
		{
			case '0':
			case 'exact':
				$optimalWidth = $newWidth;
				$optimalHeight = $newHeight;
				break;
			case '1':
			case 'portrait':
				$dimensionsArray = $this->getSizeByFixedHeight($newWidth, $newHeight);
				$optimalWidth = $dimensionsArray['optimalWidth'];
				$optimalHeight = $dimensionsArray['optimalHeight'];
				break;
			case '2':
			case 'landscape':
				$dimensionsArray = $this->getSizeByFixedWidth($newWidth, $newHeight);
				$optimalWidth = $dimensionsArray['optimalWidth'];
				$optimalHeight = $dimensionsArray['optimalHeight'];
				break;
			case '3':
			case 'auto':
				$dimensionsArray = $this->getSizeByAuto($newWidth, $newHeight);
				$optimalWidth = $dimensionsArray['optimalWidth'];
				$optimalHeight = $dimensionsArray['optimalHeight'];
				break;
			case '4':
			case 'crop':
				$dimensionsArray = $this->getOptimalCrop($newWidth, $newHeight);
				$optimalWidth = $dimensionsArray['optimalWidth'];
				$optimalHeight = $dimensionsArray['optimalHeight'];
				break;
		}

		return array( 'optimalWidth' => $optimalWidth, 'optimalHeight' => $optimalHeight );
	}

## --------------------------------------------------------

	private function getSizeByFixedHeight($newWidth, $newHeight)
	{
		// *** If forcing is off...
		if ( ! $this->forceStretch)
		{

			// *** ...check if actual height is less than target height
			if ($this->height < $newHeight)
			{
				return array( 'optimalWidth' => $this->width, 'optimalHeight' => $this->height );
			}
		}

		$ratio = $this->width / $this->height;

		$newWidth = $newHeight * $ratio;

		//return $newWidth;
		return array( 'optimalWidth' => $newWidth, 'optimalHeight' => $newHeight );
	}

## --------------------------------------------------------

	private function getSizeByFixedWidth($newWidth, $newHeight)
	{
		// *** If forcing is off...
		if ( ! $this->forceStretch)
		{

			// *** ...check if actual width is less than target width
			if ($this->width < $newWidth)
			{
				return array( 'optimalWidth' => $this->width, 'optimalHeight' => $this->height );
			}
		}

		$ratio = $this->height / $this->width;

		$newHeight = $newWidth * $ratio;

		//return $newHeight;
		return array( 'optimalWidth' => $newWidth, 'optimalHeight' => $newHeight );
	}

## --------------------------------------------------------

	private function getSizeByAuto($newWidth, $newHeight)
		# Author:     Jarrod Oberto
		# Date:       19-08-08
		# Purpose:    Depending on the height, choose to resize by 0, 1, or 2
		# Param in:   The new height and new width
		# Notes:
		#
	{
		// *** If forcing is off...
		if ( ! $this->forceStretch)
		{

			// *** ...check if actual size is less than target size
			if ($this->width < $newWidth && $this->height < $newHeight)
			{
				return array( 'optimalWidth' => $this->width, 'optimalHeight' => $this->height );
			}
		}

		if ($this->height < $this->width)
			// *** Image to be resized is wider (landscape)
		{
			//$optimalWidth = $newWidth;
			//$optimalHeight= $this->getSizeByFixedWidth($newWidth);

			$dimensionsArray = $this->getSizeByFixedWidth($newWidth, $newHeight);
			$optimalWidth = $dimensionsArray['optimalWidth'];
			$optimalHeight = $dimensionsArray['optimalHeight'];
		}
		elseif ($this->height > $this->width)
			// *** Image to be resized is taller (portrait)
		{
			//$optimalWidth = $this->getSizeByFixedHeight($newHeight);
			//$optimalHeight= $newHeight;

			$dimensionsArray = $this->getSizeByFixedHeight($newWidth, $newHeight);
			$optimalWidth = $dimensionsArray['optimalWidth'];
			$optimalHeight = $dimensionsArray['optimalHeight'];
		}
		else
			// *** Image to be resizerd is a square
		{

			if ($newHeight < $newWidth)
			{
				//$optimalWidth = $newWidth;
				//$optimalHeight= $this->getSizeByFixedWidth($newWidth);
				$dimensionsArray = $this->getSizeByFixedWidth($newWidth, $newHeight);
				$optimalWidth = $dimensionsArray['optimalWidth'];
				$optimalHeight = $dimensionsArray['optimalHeight'];
			}
			else
			{
				if ($newHeight > $newWidth)
				{
					//$optimalWidth = $this->getSizeByFixedHeight($newHeight);
					//$optimalHeight= $newHeight;
					$dimensionsArray = $this->getSizeByFixedHeight($newWidth, $newHeight);
					$optimalWidth = $dimensionsArray['optimalWidth'];
					$optimalHeight = $dimensionsArray['optimalHeight'];
				}
				else
				{
					// *** Sqaure being resized to a square
					$optimalWidth = $newWidth;
					$optimalHeight = $newHeight;
				}
			}
		}

		return array( 'optimalWidth' => $optimalWidth, 'optimalHeight' => $optimalHeight );
	}

## --------------------------------------------------------

	private function getOptimalCrop($newWidth, $newHeight)
		# Author:     Jarrod Oberto
		# Date:       17-11-09
		# Purpose:    Get optimal crop dimensions
		# Param in:   width and height as requested by user (fig 3)
		# Param out:  Array of optimal width and height (fig 2)
		# Reference:
		# Notes:      The optimal width and height return are not the same as the
		#       same as the width and height passed in. For example:
		#
		#
		#   |-----------------|     |------------|       |-------|
		#   |             |   =>  |**|      |**|   =>  |       |
		#   |             |     |**|      |**|       |       |
		#   |           |       |------------|       |-------|
		#   |-----------------|
		#        original                optimal             crop
		#              size                   size               size
		#  Fig          1                      2                  3
		#
		#       300 x 250           150 x 125          150 x 100
		#
		#    The optimal size is the smallest size (that is closest to the crop size)
		#    while retaining proportion/ratio.
		#
		#  The crop size is the optimal size that has been cropped on one axis to
		#  make the image the exact size specified by the user.
		#
		#               * represent cropped area
		#
	{

		// *** If forcing is off...
		if ( ! $this->forceStretch)
		{

			// *** ...check if actual size is less than target size
			if ($this->width < $newWidth && $this->height < $newHeight)
			{
				return array( 'optimalWidth' => $this->width, 'optimalHeight' => $this->height );
			}
		}

		$heightRatio = $this->height / $newHeight;
		$widthRatio = $this->width / $newWidth;

		if ($heightRatio < $widthRatio)
		{
			$optimalRatio = $heightRatio;
		}
		else
		{
			$optimalRatio = $widthRatio;
		}

		$optimalHeight = round($this->height / $optimalRatio);
		$optimalWidth = round($this->width / $optimalRatio);

		return array( 'optimalWidth' => $optimalWidth, 'optimalHeight' => $optimalHeight );
	}

## --------------------------------------------------------

	private function sharpen()
		# Author:     Jarrod Oberto
		# Date:       08 04 2011
		# Purpose:    Sharpen image
		# Param in:   n/a
		# Param out:  n/a
		# Reference:
		# Notes:
		# Credit:   Incorporates Joe Lencioni (August 6, 2008) code
	{

		if (version_compare(PHP_VERSION, '5.1.0') >= 0)
		{

			// ***
			if ($this->aggresiveSharpening)
			{ # A more aggressive sharpening solution

				$sharpenMatrix = array( array( -1, -1, -1 ),
										array( -1, 16, -1 ),
										array( -1, -1, -1 ) );
				$divisor = 8;
				$offset = 0;

				imageconvolution($this->imageResized, $sharpenMatrix, $divisor, $offset);
			}
			else # More subtle and personally more desirable
			{
				$sharpness = $this->findSharp($this->widthOriginal, $this->width);

				$sharpenMatrix = array(
					array( -1, -2, -1 ),
					array( -2, $sharpness + 12, -2 ), //Lessen the effect of a filter by increasing the value in the center cell
					array( -1, -2, -1 )
				);
				$divisor = $sharpness; // adjusts brightness
				$offset = 0;
				imageconvolution($this->imageResized, $sharpenMatrix, $divisor, $offset);
			}
		}
		else
		{
			if ($this->debug)
			{
				throw new Exception('Sharpening required PHP 5.1.0 or greater.');
			}
		}
	}

	## --------------------------------------------------------

	private function sharpen2($level)
	{
		$sharpenMatrix = array(
			array( $level, $level, $level ),
			array( $level, (8 * $level) + 1, $level ), //Lessen the effect of a filter by increasing the value in the center cell
			array( $level, $level, $level )
		);

	}

## --------------------------------------------------------

	private function findSharp($orig, $final)
		# Author:     Ryan Rud (http://adryrun.com)
		# Purpose:    Find optimal sharpness
		# Param in:   n/a
		# Param out:  n/a
		# Reference:
		# Notes:
		#
	{
		$final = $final * (750.0 / $orig);
		$a = 52;
		$b = -0.27810650887573124;
		$c = .00047337278106508946;

		$result = $a + $b * $final + $c * $final * $final;

		return max(round($result), 0);
	}

## --------------------------------------------------------

	private function prepOption($option)
		# Author:     Jarrod Oberto
		# Purpose:    Prep option like change the passed in option to lowercase
		# Param in:   (str/int) $option: eg. 'exact', 'crop'. 0, 4
		# Param out:  lowercase string
		# Reference:
		# Notes:
		#
	{
		if (is_array($option))
		{
			if (fix_strtolower($option[0]) == 'crop' && count($option) == 2)
			{
				return 'crop';
			}
			else
			{
				throw new Exception('Crop resize option array is badly formatted.');
			}
		}
		else
		{
			if (strpos($option, 'crop') !== false)
			{
				return 'crop';
			}
		}

		if (is_string($option))
		{
			return fix_strtolower($option);
		}

		return $option;
	}


	/*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-**-*-*-*-*-*-*-*-*-*-*-*-*-*-
  Presets
*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-**-*-*-*-*-*-*-*-*-*-*-*-*-*/

#
# Preset are pre-defined templates you can apply to your image.
#
# These are inteded to be applied to thumbnail images.
#


	public function borderPreset($preset)
	{
		switch ($preset)
		{

			case 'simple':
				$this->addBorder(7, '#fff');
				$this->addBorder(6, '#f2f1f0');
				$this->addBorder(2, '#fff');
				$this->addBorder(1, '#ccc');
				break;
			default:
				break;
		}

	}


	/*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-**-*-*-*-*-*-*-*-*-*-*-*-*-*-
  Draw border
*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-**-*-*-*-*-*-*-*-*-*-*-*-*-*/

	public function addBorder($thickness = 1, $rgbArray = array( 255, 255, 255 ))
		# Author:     Jarrod Oberto
		# Date:       05-05-11
		# Purpose:    Add a border to the image
		# Param in:
		# Param out:
		# Reference:
		# Notes:    This border is added to the INSIDE of the image
		#
	{
		if ($this->imageResized)
		{

			$rgbArray = $this->formatColor($rgbArray);
			$r = $rgbArray['r'];
			$g = $rgbArray['g'];
			$b = $rgbArray['b'];


			$x1 = 0;
			$y1 = 0;
			$x2 = ImageSX($this->imageResized) - 1;
			$y2 = ImageSY($this->imageResized) - 1;

			$rgbArray = ImageColorAllocate($this->imageResized, $r, $g, $b);


			for ($i = 0; $i < $thickness; $i++)
			{
				ImageRectangle($this->imageResized, $x1++, $y1++, $x2--, $y2--, $rgbArray);
			}
		}
	}


	/*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-**-*-*-*-*-*-*-*-*-*-*-*-*-*-
  Gray Scale
*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-**-*-*-*-*-*-*-*-*-*-*-*-*-*/

	public function greyScale()
		# Author:     Jarrod Oberto
		# Date:       07-05-2011
		# Purpose:    Make image greyscale
		# Param in:   n/a
		# Param out:
		# Reference:
		# Notes:
		#
	{
		if ($this->imageResized)
		{
			imagefilter($this->imageResized, IMG_FILTER_GRAYSCALE);
		}

	}

	## --------------------------------------------------------

	public function greyScaleEnhanced()
		# Author:     Jarrod Oberto
		# Date:       07-05-2011
		# Purpose:    Make image greyscale
		# Param in:   n/a
		# Param out:
		# Reference:
		# Notes:
		#
	{
		if ($this->imageResized)
		{
			imagefilter($this->imageResized, IMG_FILTER_GRAYSCALE);
			imagefilter($this->imageResized, IMG_FILTER_CONTRAST, -15);
			imagefilter($this->imageResized, IMG_FILTER_BRIGHTNESS, 2);
			$this->sharpen($this->width);
		}
	}

	## --------------------------------------------------------

	public function greyScaleDramatic()
		# Alias of gd_filter_monopin
	{
		$this->gd_filter_monopin();
	}


	/*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-**-*-*-*-*-*-*-*-*-*-*-*-*-*-
  Black 'n White
*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-**-*-*-*-*-*-*-*-*-*-*-*-*-*/

	public function blackAndWhite()
		# Author:     Jarrod Oberto
		# Date:       07-05-2011
		# Purpose:    Make image black and white
		# Param in:   n/a
		# Param out:
		# Reference:
		# Notes:
		#
	{
		if ($this->imageResized)
		{

			imagefilter($this->imageResized, IMG_FILTER_GRAYSCALE);
			imagefilter($this->imageResized, IMG_FILTER_CONTRAST, -1000);
		}

	}


	/*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-**-*-*-*-*-*-*-*-*-*-*-*-*-*-
  Negative
*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-**-*-*-*-*-*-*-*-*-*-*-*-*-*/

	public function negative()
		# Author:     Jarrod Oberto
		# Date:       07-05-2011
		# Purpose:    Make image negative
		# Param in:   n/a
		# Param out:
		# Reference:
		# Notes:
		#
	{
		if ($this->imageResized)
		{

			imagefilter($this->imageResized, IMG_FILTER_NEGATE);
		}

	}


	/*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-**-*-*-*-*-*-*-*-*-*-*-*-*-*-
  Sepia
*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-**-*-*-*-*-*-*-*-*-*-*-*-*-*/

	public function sepia()
		# Author:     Jarrod Oberto
		# Date:       07-05-2011
		# Purpose:    Make image sepia
		# Param in:   n/a
		# Param out:
		# Reference:
		# Notes:
		#
	{
		if ($this->imageResized)
		{
			imagefilter($this->imageResized, IMG_FILTER_GRAYSCALE);
			imagefilter($this->imageResized, IMG_FILTER_BRIGHTNESS, -10);
			imagefilter($this->imageResized, IMG_FILTER_CONTRAST, -20);
			imagefilter($this->imageResized, IMG_FILTER_COLORIZE, 60, 30, -15);
		}
	}

	## --------------------------------------------------------

	public function sepia2()

	{
		if ($this->imageResized)
		{

			$total = imagecolorstotal($this->imageResized);
			for ($i = 0; $i < $total; $i++)
			{
				$index = imagecolorsforindex($this->imageResized, $i);
				$red = ($index["red"] * 0.393 + $index["green"] * 0.769 + $index["blue"] * 0.189) / 1.351;
				$green = ($index["red"] * 0.349 + $index["green"] * 0.686 + $index["blue"] * 0.168) / 1.203;
				$blue = ($index["red"] * 0.272 + $index["green"] * 0.534 + $index["blue"] * 0.131) / 2.140;
				imagecolorset($this->imageResized, $i, $red, $green, $blue);
			}


		}
	}


	/*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-**-*-*-*-*-*-*-*-*-*-*-*-*-*-
  Vintage
*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-**-*-*-*-*-*-*-*-*-*-*-*-*-*/

	public function vintage()
		# Alias of gd_filter_monopin
	{
		$this->gd_filter_vintage();
	}

	/*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-**-*-*-*-*-*-*-*-*-*-*-*-*-*-
  Presets By Marc Hibbins
*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-**-*-*-*-*-*-*-*-*-*-*-*-*-*/


	/** Apply 'Monopin' preset */
	public function gd_filter_monopin()
	{

		if ($this->imageResized)
		{
			imagefilter($this->imageResized, IMG_FILTER_GRAYSCALE);
			imagefilter($this->imageResized, IMG_FILTER_BRIGHTNESS, -15);
			imagefilter($this->imageResized, IMG_FILTER_CONTRAST, -15);
			$this->imageResized = $this->gd_apply_overlay($this->imageResized, 'vignette', 100);
		}
	}

	## --------------------------------------------------------

	public function gd_filter_vintage()
	{
		if ($this->imageResized)
		{
			$this->imageResized = $this->gd_apply_overlay($this->imageResized, 'vignette', 45);
			imagefilter($this->imageResized, IMG_FILTER_BRIGHTNESS, 20);
			imagefilter($this->imageResized, IMG_FILTER_CONTRAST, -35);
			imagefilter($this->imageResized, IMG_FILTER_COLORIZE, 60, -10, 35);
			imagefilter($this->imageResized, IMG_FILTER_SMOOTH, 7);
			$this->imageResized = $this->gd_apply_overlay($this->imageResized, 'scratch', 10);
		}
	}

	## --------------------------------------------------------

	/** Apply a PNG overlay */
	private function gd_apply_overlay($im, $type, $amount)
		#
		# Original Author:    Marc Hibbins
		# License:  Attribution-ShareAlike 3.0
		# Purpose:
		# Params in:
		# Params out:
		# Notes:
		#
	{
		$width = imagesx($im);
		$height = imagesy($im);
		$filter = imagecreatetruecolor($width, $height);

		imagealphablending($filter, false);
		imagesavealpha($filter, true);

		$transparent = imagecolorallocatealpha($filter, 255, 255, 255, 127);
		imagefilledrectangle($filter, 0, 0, $width, $height, $transparent);

		// *** Resize overlay
		$overlay = $this->filterOverlayPath . '/' . $type . '.png';
		$png = imagecreatefrompng($overlay);
		imagecopyresampled($filter, $png, 0, 0, 0, 0, $width, $height, imagesx($png), imagesy($png));

		$comp = imagecreatetruecolor($width, $height);
		imagecopy($comp, $im, 0, 0, 0, 0, $width, $height);
		imagecopy($comp, $filter, 0, 0, 0, 0, $width, $height);
		imagecopymerge($im, $comp, 0, 0, 0, 0, $width, $height, $amount);

		imagedestroy($comp);

		return $im;
	}


	/*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-**-*-*-*-*-*-*-*-*-*-*-*-*-*-
  Colorise
*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-**-*-*-*-*-*-*-*-*-*-*-*-*-*/

	public function image_colorize($rgb)
	{
		imageTrueColorToPalette($this->imageResized, true, 256);
		$numColors = imageColorsTotal($this->imageResized);

		for ($x = 0; $x < $numColors; $x++)
		{
			list($r, $g, $b) = array_values(imageColorsForIndex($this->imageResized, $x));

			// calculate grayscale in percent
			$grayscale = ($r + $g + $b) / 3 / 0xff;

			imageColorSet($this->imageResized, $x,
				$grayscale * $rgb[0],
				$grayscale * $rgb[1],
				$grayscale * $rgb[2]
			);

		}

		return true;
	}


	/*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-**-*-*-*-*-*-*-*-*-*-*-*-*-*-
  Reflection
*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-**-*-*-*-*-*-*-*-*-*-*-*-*-*/

	public function addReflection($reflectionHeight = 50, $startingTransparency = 30, $inside = false, $bgColor = '#fff', $stretch = false, $divider = 0)
	{

		// *** Convert color
		$rgbArray = $this->formatColor($bgColor);
		$r = $rgbArray['r'];
		$g = $rgbArray['g'];
		$b = $rgbArray['b'];

		$im = $this->imageResized;
		$li = imagecreatetruecolor($this->width, 1);

		$bgc = imagecolorallocate($li, $r, $g, $b);
		imagefilledrectangle($li, 0, 0, $this->width, 1, $bgc);

		$bg = imagecreatetruecolor($this->width, $reflectionHeight);
		$wh = imagecolorallocate($im, 255, 255, 255);

		$im = imagerotate($im, -180, $wh);
		imagecopyresampled($bg, $im, 0, 0, 0, 0, $this->width, $this->height, $this->width, $this->height);

		$im = $bg;

		$bg = imagecreatetruecolor($this->width, $reflectionHeight);

		for ($x = 0; $x < $this->width; $x++)
		{
			imagecopy($bg, $im, $x, 0, $this->width - $x - 1, 0, 1, $reflectionHeight);
		}
		$im = $bg;

		$transaprencyAmount = $this->invertTransparency($startingTransparency, 100);


		// *** Fade
		if ($stretch)
		{
			$step = 100 / ($reflectionHeight + $startingTransparency);
		}
		else
		{
			$step = 100 / $reflectionHeight;
		}
		for ($i = 0; $i <= $reflectionHeight; $i++)
		{

			if ($startingTransparency > 100)
			{
				$startingTransparency = 100;
			}
			if ($startingTransparency < 1)
			{
				$startingTransparency = 1;
			}
			imagecopymerge($bg, $li, 0, $i, 0, 0, $this->width, 1, $startingTransparency);
			$startingTransparency += $step;
		}

		// *** Apply fade
		imagecopymerge($im, $li, 0, 0, 0, 0, $this->width, $divider, 100); // Divider


		// *** width, height of reflection.
		$x = imagesx($im);
		$y = imagesy($im);


		// *** Determines if the reflection should be displayed inside or outside the image
		if ($inside)
		{

			// Create new blank image with sizes.
			$final = imagecreatetruecolor($this->width, $this->height);

			imagecopymerge($final, $this->imageResized, 0, 0, 0, $reflectionHeight, $this->width, $this->height - $reflectionHeight, 100);
			imagecopymerge($final, $im, 0, $this->height - $reflectionHeight, 0, 0, $x, $y, 100);

		}
		else
		{

			// Create new blank image with sizes.
			$final = imagecreatetruecolor($this->width, $this->height + $y);

			imagecopymerge($final, $this->imageResized, 0, 0, 0, 0, $this->width, $this->height, 100);
			imagecopymerge($final, $im, 0, $this->height, 0, 0, $x, $y, 100);
		}

		$this->imageResized = $final;

		imagedestroy($li);
		imagedestroy($im);
	}


	/*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-**-*-*-*-*-*-*-*-*-*-*-*-*-*-
  Rotate
*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-**-*-*-*-*-*-*-*-*-*-*-*-*-*/

	public function rotate($value = 90, $bgColor = 'transparent')
		# Author:     Jarrod Oberto
		# Date:       07-05-2011
		# Purpose:    Rotate image
		# Param in:   (mixed) $degrees: (int) number of degress to rotate image
		#               (str) param "left": rotate left
		#               (str) param "right": rotate right
		#               (str) param "upside": upside-down image
		# Param out:
		# Reference:
		# Notes:    The default direction of imageRotate() is counter clockwise.
		#
	{
		if ($this->imageResized)
		{

			if (is_integer($value))
			{
				$degrees = $value;
			}

			// *** Convert color
			$rgbArray = $this->formatColor($bgColor);
			$r = $rgbArray['r'];
			$g = $rgbArray['g'];
			$b = $rgbArray['b'];
			if (isset($rgbArray['a']))
			{
				$a = $rgbArray['a'];
			}

			if (is_string($value))
			{

				$value = fix_strtolower($value);

				switch ($value)
				{
					case 'left':
						$degrees = 90;
						break;
					case 'right':
						$degrees = 270;
						break;
					case 'upside':
						$degrees = 180;
						break;
					default:
						break;
				}

			}

			// *** The default direction of imageRotate() is counter clockwise
			//   * This makes it clockwise
			$degrees = 360 - $degrees;

			// *** Create background color
			$bg = ImageColorAllocateAlpha($this->imageResized, $r, $g, $b, $a);

			// *** Fill with background
			ImageFill($this->imageResized, 0, 0, $bg);

			// *** Rotate
			$this->imageResized = imagerotate($this->imageResized, $degrees, $bg); // Rotate 45 degrees and allocated the transparent colour as the one to make transparent (obviously)

			// Ensure alpha transparency
			ImageSaveAlpha($this->imageResized, true);

		}
	}


	/*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-**-*-*-*-*-*-*-*-*-*-*-*-*-*-
  Round corners
*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-**-*-*-*-*-*-*-*-*-*-*-*-*-*/

	public function roundCorners($radius = 5, $bgColor = 'transparent')
		# Author:     Jarrod Oberto
		# Date:       19-05-2011
		# Purpose:    Create rounded corners on your image
		# Param in:   (int) radius = the amount of curvature
		#       (mixed) $bgColor = the corner background color
		# Param out:  n/a
		# Reference:
		# Notes:
		#
	{

		// *** Check if the user wants transparency
		$isTransparent = false;
		if ( ! is_array($bgColor))
		{
			if (fix_strtolower($bgColor) == 'transparent')
			{
				$isTransparent = true;
			}
		}


		// *** If we use transparency, we need to color our curved mask with a unique color
		if ($isTransparent)
		{
			$bgColor = $this->findUnusedGreen();
		}

		// *** Convert color
		$rgbArray = $this->formatColor($bgColor);
		$r = $rgbArray['r'];
		$g = $rgbArray['g'];
		$b = $rgbArray['b'];
		if (isset($rgbArray['a']))
		{
			$a = $rgbArray['a'];
		}


		// *** Create top-left corner mask (square)
		$cornerImg = imagecreatetruecolor($radius, $radius);
		//$cornerImg = imagecreate($radius, $radius);

		//imagealphablending($cornerImg, true);
		//imagesavealpha($cornerImg, true);

		//imagealphablending($this->imageResized, false);
		//imagesavealpha($this->imageResized, true);

		// *** Give it a color
		$maskColor = imagecolorallocate($cornerImg, 0, 0, 0);


		// *** Replace the mask color (black) to transparent
		imagecolortransparent($cornerImg, $maskColor);


		// *** Create the image background color
		$imagebgColor = imagecolorallocate($cornerImg, $r, $g, $b);


		// *** Fill the corner area to the user defined color
		imagefill($cornerImg, 0, 0, $imagebgColor);


		imagefilledellipse($cornerImg, $radius, $radius, $radius * 2, $radius * 2, $maskColor);


		// *** Map to top left corner
		imagecopymerge($this->imageResized, $cornerImg, 0, 0, 0, 0, $radius, $radius, 100); #tl

		// *** Map rounded corner to other corners by rotating and applying the mask
		$cornerImg = imagerotate($cornerImg, 90, 0);
		imagecopymerge($this->imageResized, $cornerImg, 0, $this->height - $radius, 0, 0, $radius, $radius, 100); #bl

		$cornerImg = imagerotate($cornerImg, 90, 0);
		imagecopymerge($this->imageResized, $cornerImg, $this->width - $radius, $this->height - $radius, 0, 0, $radius, $radius, 100); #br

		$cornerImg = imagerotate($cornerImg, 90, 0);
		imagecopymerge($this->imageResized, $cornerImg, $this->width - $radius, 0, 0, 0, $radius, $radius, 100); #tr


		// *** If corners are to be transparent, we fill our chromakey color as transparent.
		if ($isTransparent)
		{
			//imagecolortransparent($this->imageResized, $imagebgColor);
			$this->imageResized = $this->transparentImage($this->imageResized);
			imagesavealpha($this->imageResized, true);
		}

	}


	/*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-**-*-*-*-*-*-*-*-*-*-*-*-*-*-
  Shadow
*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-**-*-*-*-*-*-*-*-*-*-*-*-*-*/

	public function addShadow($shadowAngle = 45, $blur = 15, $bgColor = 'transparent')
		#
		# Author:   Jarrod Oberto (Adapted from Pascal Naidon)
		# Ref:    http://www.les-stooges.org/pascal/webdesign/vignettes/index.php?la=en
		# Purpose:  Add a drop shadow to your image
		# Params in:  (int) $angle: the angle of the shadow
		#       (int) $blur: the blur distance
		#       (mixed) $bgColor: the color of the background
		# Params out:
		# Notes:
		#
	{
		// *** A higher number results in a smoother shadow
		define('STEPS', $blur * 2);

		// *** Set the shadow distance
		$shadowDistance = $blur * 0.25;

		// *** Set blur width and height
		$blurWidth = $blurHeight = $blur;


		if ($shadowAngle == 0)
		{
			$distWidth = 0;
			$distHeight = 0;
		}
		else
		{
			$distWidth = $shadowDistance * cos(deg2rad($shadowAngle));
			$distHeight = $shadowDistance * sin(deg2rad($shadowAngle));
		}


		// *** Convert color
		if (fix_strtolower($bgColor) != 'transparent')
		{
			$rgbArray = $this->formatColor($bgColor);
			$r0 = $rgbArray['r'];
			$g0 = $rgbArray['g'];
			$b0 = $rgbArray['b'];
		}


		$image = $this->imageResized;
		$width = $this->width;
		$height = $this->height;


		$newImage = imagecreatetruecolor($width, $height);
		imagecopyresampled($newImage, $image, 0, 0, 0, 0, $width, $height, $width, $height);


		// *** RGB
		$rgb = imagecreatetruecolor($width + $blurWidth, $height + $blurHeight);
		$colour = imagecolorallocate($rgb, 0, 0, 0);
		imagefilledrectangle($rgb, 0, 0, $width + $blurWidth, $height + $blurHeight, $colour);
		$colour = imagecolorallocate($rgb, 255, 255, 255);
		//imagefilledrectangle($rgb, $blurWidth*0.5-$distWidth, $blurHeight*0.5-$distHeight, $width+$blurWidth*0.5-$distWidth, $height+$blurWidth*0.5-$distHeight, $colour);
		imagefilledrectangle($rgb, $blurWidth * 0.5 - $distWidth, $blurHeight * 0.5 - $distHeight, $width + $blurWidth * 0.5 - $distWidth, $height + $blurWidth * 0.5 - $distHeight, $colour);
		//imagecopymerge($rgb, $newImage, 1+$blurWidth*0.5-$distWidth, 1+$blurHeight*0.5-$distHeight, 0,0, $width, $height, 100);
		imagecopymerge($rgb, $newImage, $blurWidth * 0.5 - $distWidth, $blurHeight * 0.5 - $distHeight, 0, 0, $width + $blurWidth, $height + $blurHeight, 100);


		// *** Shadow (alpha)
		$shadow = imagecreatetruecolor($width + $blurWidth, $height + $blurHeight);
		imagealphablending($shadow, false);
		$colour = imagecolorallocate($shadow, 0, 0, 0);
		imagefilledrectangle($shadow, 0, 0, $width + $blurWidth, $height + $blurHeight, $colour);


		for ($i = 0; $i <= STEPS; $i++)
		{

			$t = ((1.0 * $i) / STEPS);
			$intensity = 255 * $t * $t;

			$colour = imagecolorallocate($shadow, $intensity, $intensity, $intensity);
			$points = array(
				$blurWidth * $t, $blurHeight,     // Point 1 (x, y)
				$blurWidth, $blurHeight * $t,  // Point 2 (x, y)
				$width, $blurHeight * $t,  // Point 3 (x, y)
				$width + $blurWidth * (1 - $t), $blurHeight,     // Point 4 (x, y)
				$width + $blurWidth * (1 - $t), $height,     // Point 5 (x, y)
				$width, $height + $blurHeight * (1 - $t),  // Point 6 (x, y)
				$blurWidth, $height + $blurHeight * (1 - $t),  // Point 7 (x, y)
				$blurWidth * $t, $height      // Point 8 (x, y)
			);
			imagepolygon($shadow, $points, 8, $colour);
		}

		for ($i = 0; $i <= STEPS; $i++)
		{

			$t = ((1.0 * $i) / STEPS);
			$intensity = 255 * $t * $t;

			$colour = imagecolorallocate($shadow, $intensity, $intensity, $intensity);
			imagefilledarc($shadow, $blurWidth - 1, $blurHeight - 1, 2 * (1 - $t) * $blurWidth, 2 * (1 - $t) * $blurHeight, 180, 268, $colour, IMG_ARC_PIE);
			imagefilledarc($shadow, $width, $blurHeight - 1, 2 * (1 - $t) * $blurWidth, 2 * (1 - $t) * $blurHeight, 270, 358, $colour, IMG_ARC_PIE);
			imagefilledarc($shadow, $width, $height, 2 * (1 - $t) * $blurWidth, 2 * (1 - $t) * $blurHeight, 0, 90, $colour, IMG_ARC_PIE);
			imagefilledarc($shadow, $blurWidth - 1, $height, 2 * (1 - $t) * $blurWidth, 2 * (1 - $t) * $blurHeight, 90, 180, $colour, IMG_ARC_PIE);
		}


		$colour = imagecolorallocate($shadow, 255, 255, 255);
		imagefilledrectangle($shadow, $blurWidth, $blurHeight, $width, $height, $colour);
		imagefilledrectangle($shadow, $blurWidth * 0.5 - $distWidth, $blurHeight * 0.5 - $distHeight, $width + $blurWidth * 0.5 - 1 - $distWidth, $height + $blurHeight * 0.5 - 1 - $distHeight, $colour);


		// *** The magic
		imagealphablending($rgb, false);

		for ($theX = 0; $theX < imagesx($rgb); $theX++)
		{
			for ($theY = 0; $theY < imagesy($rgb); $theY++)
			{

				// *** Get the RGB values for every pixel of the RGB image
				$colArray = imagecolorat($rgb, $theX, $theY);
				$r = ($colArray >> 16) & 0xFF;
				$g = ($colArray >> 8) & 0xFF;
				$b = $colArray & 0xFF;

				// *** Get the alpha value for every pixel of the shadow image
				$colArray = imagecolorat($shadow, $theX, $theY);
				$a = $colArray & 0xFF;
				$a = 127 - floor($a / 2);
				$t = $a / 128.0;

				// *** Create color
				if (fix_strtolower($bgColor) == 'transparent')
				{
					$myColour = imagecolorallocatealpha($rgb, $r, $g, $b, $a);
				}
				else
				{
					$myColour = imagecolorallocate($rgb, $r * (1.0 - $t) + $r0 * $t, $g * (1.0 - $t) + $g0 * $t, $b * (1.0 - $t) + $b0 * $t);
				}

				// *** Add color to new rgb image
				imagesetpixel($rgb, $theX, $theY, $myColour);
			}
		}

		imagealphablending($rgb, true);
		imagesavealpha($rgb, true);

		$this->imageResized = $rgb;

		imagedestroy($image);
		imagedestroy($newImage);
		imagedestroy($shadow);
	}


	/*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-**-*-*-*-*-*-*-*-*-*-*-*-*-*-
  Add Caption Box
*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-**-*-*-*-*-*-*-*-*-*-*-*-*-*/

	public function addCaptionBox($side = 'b', $thickness = 50, $padding = 0, $bgColor = '#000', $transaprencyAmount = 30)
		#
		# Author:   Jarrod Oberto
		# Date:   26 May 2011
		# Purpose:  Add a caption box
		# Params in:  (str) $side: the side to add the caption box (t, r, b, or l).
		#       (int) $thickness: how thick you want the caption box to be.
		#       (mixed) $bgColor: The color of the caption box.
		#       (int) $transaprencyAmount: The amount of transparency to be
		#       applied.
		# Params out: n/a
		# Notes:
		#
	{
		$side = fix_strtolower($side);

		// *** Convert color
		$rgbArray = $this->formatColor($bgColor);
		$r = $rgbArray['r'];
		$g = $rgbArray['g'];
		$b = $rgbArray['b'];

		$positionArray = $this->calculateCaptionBoxPosition($side, $thickness, $padding);

		// *** Store incase we want to use method addTextToCaptionBox()
		$this->captionBoxPositionArray = $positionArray;


		$transaprencyAmount = $this->invertTransparency($transaprencyAmount, 127, false);
		$transparent = imagecolorallocatealpha($this->imageResized, $r, $g, $b, $transaprencyAmount);
		imagefilledrectangle($this->imageResized, $positionArray['x1'], $positionArray['y1'], $positionArray['x2'], $positionArray['y2'], $transparent);
	}

	## --------------------------------------------------------

	public function addTextToCaptionBox($text, $fontColor = '#fff', $fontSize = 12, $angle = 0, $font = null)
		#
		# Author:   Jarrod Oberto
		# Date:   03 Aug 11
		# Purpose:  Simplify adding text to a caption box by automatically
		#       locating the center of the caption box
		# Params in:  The usually text paams (less a couple)
		# Params out: n/a
		# Notes:
		#
	{

		// *** Get the caption box measurements
		if (count($this->captionBoxPositionArray) == 4)
		{
			$x1 = $this->captionBoxPositionArray['x1'];
			$x2 = $this->captionBoxPositionArray['x2'];
			$y1 = $this->captionBoxPositionArray['y1'];
			$y2 = $this->captionBoxPositionArray['y2'];
		}
		else
		{
			if ($this->debug)
			{
				throw new Exception('No caption box found.');
			}
			else
			{
				return false;
			}
		}


		// *** Get text font
		$font = $this->getTextFont($font);

		// *** Get text size
		$textSizeArray = $this->getTextSize($fontSize, $angle, $font, $text);
		$textWidth = $textSizeArray['width'];
		$textHeight = $textSizeArray['height'];

		// *** Find the width/height middle points
		$boxXMiddle = (($x2 - $x1) / 2);
		$boxYMiddle = (($y2 - $y1) / 2);

		// *** Box middle - half the text width/height
		$xPos = ($x1 + $boxXMiddle) - ($textWidth / 2);
		$yPos = ($y1 + $boxYMiddle) - ($textHeight / 2);

		$pos = $xPos . 'x' . $yPos;

		$this->addText($text, $pos, $padding = 0, $fontColor, $fontSize, $angle, $font);

	}

	## --------------------------------------------------------

	private function calculateCaptionBoxPosition($side, $thickness, $padding)
	{
		$positionArray = array();

		switch ($side)
		{
			case 't':
				$positionArray['x1'] = 0;
				$positionArray['y1'] = $padding;
				$positionArray['x2'] = $this->width;
				$positionArray['y2'] = $thickness + $padding;
				break;
			case 'r':
				$positionArray['x1'] = $this->width - $thickness - $padding;
				$positionArray['y1'] = 0;
				$positionArray['x2'] = $this->width - $padding;
				$positionArray['y2'] = $this->height;
				break;
			case 'b':
				$positionArray['x1'] = 0;
				$positionArray['y1'] = $this->height - $thickness - $padding;
				$positionArray['x2'] = $this->width;
				$positionArray['y2'] = $this->height - $padding;
				break;
			case 'l':
				$positionArray['x1'] = $padding;
				$positionArray['y1'] = 0;
				$positionArray['x2'] = $thickness + $padding;
				$positionArray['y2'] = $this->height;
				break;

			default:
				break;
		}

		return $positionArray;

	}

	/*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-**-*-*-*-*-*-*-*-*-*-*-*-*-*-
  Get EXIF Data
*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-**-*-*-*-*-*-*-*-*-*-*-*-*-*/

	public function getExif($debug = false)
		# Author:     Jarrod Oberto
		# Date:       07-05-2011
		# Purpose:    Get image EXIF data
		# Param in:   n/a
		# Param out:  An associate array of EXIF data
		# Reference:
		# Notes:
		# 23 May 13 : added orientation flag -jco
		#
	{

		if ( ! $this->debug || ! $debug)
		{
			$debug = false;
		}

		// *** Check all is good - check the EXIF library exists and the file exists, too.
		if ( ! $this->testEXIFInstalled())
		{
			if ($debug)
			{
				throw new Exception('The EXIF Library is not installed.');
			}
			else
			{
				return array();
			}
		};
		if ( ! file_exists($this->fileName))
		{
			if ($debug)
			{
				throw new Exception('Image not found.');
			}
			else
			{
				return array();
			}
		};
		if ($this->fileExtension != '.jpg')
		{
			if ($debug)
			{
				throw new Exception('Metadata not supported for this image type.');
			}
			else
			{
				return array();
			}
		};
		$exifData = exif_read_data($this->fileName, 'IFD0');

		// *** Format the apperture value
		$ev = $exifData['ApertureValue'];
		$apPeicesArray = explode('/', $ev);
		if (count($apPeicesArray) == 2)
		{
			$apertureValue = round($apPeicesArray[0] / $apPeicesArray[1], 2, PHP_ROUND_HALF_DOWN) . ' EV';
		}
		else
		{
			$apertureValue = '';
		}

		// *** Format the focal length
		$focalLength = $exifData['FocalLength'];
		$flPeicesArray = explode('/', $focalLength);
		if (count($flPeicesArray) == 2)
		{
			$focalLength = $flPeicesArray[0] / $flPeicesArray[1] . '.0 mm';
		}
		else
		{
			$focalLength = '';
		}

		// *** Format fNumber
		$fNumber = $exifData['FNumber'];
		$fnPeicesArray = explode('/', $fNumber);
		if (count($fnPeicesArray) == 2)
		{
			$fNumber = $fnPeicesArray[0] / $fnPeicesArray[1];
		}
		else
		{
			$fNumber = '';
		}

		// *** Resolve ExposureProgram
		if (isset($exifData['ExposureProgram']))
		{
			$ep = $exifData['ExposureProgram'];
		}
		if (isset($ep))
		{
			$ep = $this->resolveExposureProgram($ep);
		}


		// *** Resolve MeteringMode
		$mm = $exifData['MeteringMode'];
		$mm = $this->resolveMeteringMode($mm);

		// *** Resolve Flash
		$flash = $exifData['Flash'];
		$flash = $this->resolveFlash($flash);


		if (isset($exifData['Make']))
		{
			$exifDataArray['make'] = $exifData['Make'];
		}
		else
		{
			$exifDataArray['make'] = '';
		}

		if (isset($exifData['Model']))
		{
			$exifDataArray['model'] = $exifData['Model'];
		}
		else
		{
			$exifDataArray['model'] = '';
		}

		if (isset($exifData['DateTime']))
		{
			$exifDataArray['date'] = $exifData['DateTime'];
		}
		else
		{
			$exifDataArray['date'] = '';
		}

		if (isset($exifData['ExposureTime']))
		{
			$exifDataArray['exposure time'] = $exifData['ExposureTime'] . ' sec.';
		}
		else
		{
			$exifDataArray['exposure time'] = '';
		}

		if ($apertureValue != '')
		{
			$exifDataArray['aperture value'] = $apertureValue;
		}
		else
		{
			$exifDataArray['aperture value'] = '';
		}

		if (isset($exifData['COMPUTED']['ApertureFNumber']))
		{
			$exifDataArray['f-stop'] = $exifData['COMPUTED']['ApertureFNumber'];
		}
		else
		{
			$exifDataArray['f-stop'] = '';
		}

		if (isset($exifData['FNumber']))
		{
			$exifDataArray['fnumber'] = $exifData['FNumber'];
		}
		else
		{
			$exifDataArray['fnumber'] = '';
		}

		if ($fNumber != '')
		{
			$exifDataArray['fnumber value'] = $fNumber;
		}
		else
		{
			$exifDataArray['fnumber value'] = '';
		}

		if (isset($exifData['ISOSpeedRatings']))
		{
			$exifDataArray['iso'] = $exifData['ISOSpeedRatings'];
		}
		else
		{
			$exifDataArray['iso'] = '';
		}

		if ($focalLength != '')
		{
			$exifDataArray['focal length'] = $focalLength;
		}
		else
		{
			$exifDataArray['focal length'] = '';
		}

		if (isset($ep))
		{
			$exifDataArray['exposure program'] = $ep;
		}
		else
		{
			$exifDataArray['exposure program'] = '';
		}

		if ($mm != '')
		{
			$exifDataArray['metering mode'] = $mm;
		}
		else
		{
			$exifDataArray['metering mode'] = '';
		}

		if ($flash != '')
		{
			$exifDataArray['flash status'] = $flash;
		}
		else
		{
			$exifDataArray['flash status'] = '';
		}

		if (isset($exifData['Artist']))
		{
			$exifDataArray['creator'] = $exifData['Artist'];
		}
		else
		{
			$exifDataArray['creator'] = '';
		}

		if (isset($exifData['Copyright']))
		{
			$exifDataArray['copyright'] = $exifData['Copyright'];
		}
		else
		{
			$exifDataArray['copyright'] = '';
		}

		// *** Orientation
		if (isset($exifData['Orientation']))
		{
			$exifDataArray['orientation'] = $exifData['Orientation'];
		}
		else
		{
			$exifDataArray['orientation'] = '';
		}

		return $exifDataArray;
	}

	## --------------------------------------------------------

	private function resolveExposureProgram($ep)
	{
		switch ($ep)
		{
			case 0:
				$ep = '';
				break;
			case 1:
				$ep = 'manual';
				break;
			case 2:
				$ep = 'normal program';
				break;
			case 3:
				$ep = 'aperture priority';
				break;
			case 4:
				$ep = 'shutter priority';
				break;
			case 5:
				$ep = 'creative program';
				break;
			case 6:
				$ep = 'action program';
				break;
			case 7:
				$ep = 'portrait mode';
				break;
			case 8:
				$ep = 'landscape mode';
				break;

			default:
				break;
		}

		return $ep;
	}

	## --------------------------------------------------------

	private function resolveMeteringMode($mm)
	{
		switch ($mm)
		{
			case 0:
				$mm = 'unknown';
				break;
			case 1:
				$mm = 'average';
				break;
			case 2:
				$mm = 'center weighted average';
				break;
			case 3:
				$mm = 'spot';
				break;
			case 4:
				$mm = 'multi spot';
				break;
			case 5:
				$mm = 'pattern';
				break;
			case 6:
				$mm = 'partial';
				break;
			case 255:
				$mm = 'other';
				break;

			default:
				break;
		}

		return $mm;
	}

	## --------------------------------------------------------

	private function resolveFlash($flash)
	{
		switch ($flash)
		{
			case 0:
				$flash = 'flash did not fire';
				break;
			case 1:
				$flash = 'flash fired';
				break;
			case 5:
				$flash = 'strobe return light not detected';
				break;
			case 7:
				$flash = 'strobe return light detected';
				break;
			case 9:
				$flash = 'flash fired, compulsory flash mode';
				break;
			case 13:
				$flash = 'flash fired, compulsory flash mode, return light not detected';
				break;
			case 15:
				$flash = 'flash fired, compulsory flash mode, return light detected';
				break;
			case 16:
				$flash = 'flash did not fire, compulsory flash mode';
				break;
			case 24:
				$flash = 'flash did not fire, auto mode';
				break;
			case 25:
				$flash = 'flash fired, auto mode';
				break;
			case 29:
				$flash = 'flash fired, auto mode, return light not detected';
				break;
			case 31:
				$flash = 'flash fired, auto mode, return light detected';
				break;
			case 32:
				$flash = 'no flash function';
				break;
			case 65:
				$flash = 'flash fired, red-eye reduction mode';
				break;
			case 69:
				$flash = 'flash fired, red-eye reduction mode, return light not detected';
				break;
			case 71:
				$flash = 'flash fired, red-eye reduction mode, return light detected';
				break;
			case 73:
				$flash = 'flash fired, compulsory flash mode, red-eye reduction mode';
				break;
			case 77:
				$flash = 'flash fired, compulsory flash mode, red-eye reduction mode, return light not detected';
				break;
			case 79:
				$flash = 'flash fired, compulsory flash mode, red-eye reduction mode, return light detected';
				break;
			case 89:
				$flash = 'flash fired, auto mode, red-eye reduction mode';
				break;
			case 93:
				$flash = 'flash fired, auto mode, return light not detected, red-eye reduction mode';
				break;
			case 95:
				$flash = 'flash fired, auto mode, return light detected, red-eye reductio




Copyright © 2015-2019 - by Lucas SOS | About the Author | Tags | Blog | Links | Login