Andrey Andreev | c576995 | 2019-01-16 17:49:35 +0200 | [diff] [blame] | 1 | |
| 2 | |
| 3 | <!DOCTYPE html> |
| 4 | <!--[if IE 8]><html class="no-js lt-ie9" lang="en" > <![endif]--> |
| 5 | <!--[if gt IE 8]><!--> <html class="no-js" lang="en" > <!--<![endif]--> |
| 6 | <head> |
| 7 | <meta charset="utf-8"> |
| 8 | <meta name="viewport" content="width=device-width, initial-scale=1.0"> |
| 9 | |
| 10 | <title>Image Manipulation Class — CodeIgniter 3.1.10 documentation</title> |
| 11 | |
| 12 | |
| 13 | |
| 14 | |
| 15 | <link rel="shortcut icon" href="../_static/ci-icon.ico"/> |
| 16 | |
| 17 | |
| 18 | |
| 19 | <link href='https://fonts.googleapis.com/css?family=Lato:400,700,400italic,700italic|Roboto+Slab:400,700|Inconsolata:400,700&subset=latin,cyrillic' rel='stylesheet' type='text/css'> |
| 20 | |
| 21 | |
| 22 | |
| 23 | |
| 24 | |
| 25 | |
| 26 | |
| 27 | |
| 28 | |
| 29 | <link rel="stylesheet" href="../_static/css/citheme.css" type="text/css" /> |
| 30 | |
| 31 | |
| 32 | |
| 33 | <link rel="index" title="Index" |
| 34 | href="../genindex.html"/> |
| 35 | <link rel="search" title="Search" href="../search.html"/> |
| 36 | <link rel="top" title="CodeIgniter 3.1.10 documentation" href="../index.html"/> |
| 37 | <link rel="up" title="Libraries" href="index.html"/> |
| 38 | <link rel="next" title="Input Class" href="input.html"/> |
| 39 | <link rel="prev" title="FTP Class" href="ftp.html"/> |
| 40 | |
| 41 | |
| 42 | <script src="https://cdnjs.cloudflare.com/ajax/libs/modernizr/2.6.2/modernizr.min.js"></script> |
| 43 | |
| 44 | </head> |
| 45 | |
| 46 | <body class="wy-body-for-nav" role="document"> |
| 47 | |
| 48 | <div id="nav"> |
| 49 | <div id="nav_inner"> |
| 50 | |
| 51 | |
| 52 | |
| 53 | <div id="pulldown-menu" class="ciNav"> |
| 54 | <ul> |
| 55 | <li class="toctree-l1"><a class="reference internal" href="../general/welcome.html">Welcome to CodeIgniter</a></li> |
| 56 | </ul> |
| 57 | <ul> |
| 58 | <li class="toctree-l1"><a class="reference internal" href="../installation/index.html">Installation Instructions</a><ul> |
| 59 | <li class="toctree-l2"><a class="reference internal" href="../installation/downloads.html">Downloading CodeIgniter</a></li> |
| 60 | <li class="toctree-l2"><a class="reference internal" href="../installation/index.html">Installation Instructions</a></li> |
| 61 | <li class="toctree-l2"><a class="reference internal" href="../installation/upgrading.html">Upgrading From a Previous Version</a></li> |
| 62 | <li class="toctree-l2"><a class="reference internal" href="../installation/troubleshooting.html">Troubleshooting</a></li> |
| 63 | </ul> |
| 64 | </li> |
| 65 | </ul> |
| 66 | <ul> |
| 67 | <li class="toctree-l1"><a class="reference internal" href="../overview/index.html">CodeIgniter Overview</a><ul> |
| 68 | <li class="toctree-l2"><a class="reference internal" href="../overview/getting_started.html">Getting Started</a></li> |
| 69 | <li class="toctree-l2"><a class="reference internal" href="../overview/at_a_glance.html">CodeIgniter at a Glance</a></li> |
| 70 | <li class="toctree-l2"><a class="reference internal" href="../overview/features.html">Supported Features</a></li> |
| 71 | <li class="toctree-l2"><a class="reference internal" href="../overview/appflow.html">Application Flow Chart</a></li> |
| 72 | <li class="toctree-l2"><a class="reference internal" href="../overview/mvc.html">Model-View-Controller</a></li> |
| 73 | <li class="toctree-l2"><a class="reference internal" href="../overview/goals.html">Architectural Goals</a></li> |
| 74 | </ul> |
| 75 | </li> |
| 76 | </ul> |
| 77 | <ul> |
| 78 | <li class="toctree-l1"><a class="reference internal" href="../tutorial/index.html">Tutorial</a><ul> |
| 79 | <li class="toctree-l2"><a class="reference internal" href="../tutorial/static_pages.html">Static pages</a></li> |
| 80 | <li class="toctree-l2"><a class="reference internal" href="../tutorial/news_section.html">News section</a></li> |
| 81 | <li class="toctree-l2"><a class="reference internal" href="../tutorial/create_news_items.html">Create news items</a></li> |
| 82 | <li class="toctree-l2"><a class="reference internal" href="../tutorial/conclusion.html">Conclusion</a></li> |
| 83 | </ul> |
| 84 | </li> |
| 85 | </ul> |
| 86 | <ul> |
| 87 | <li class="toctree-l1"><a class="reference internal" href="../contributing/index.html">Contributing to CodeIgniter</a><ul> |
| 88 | <li class="toctree-l2"><a class="reference internal" href="../documentation/index.html">Writing CodeIgniter Documentation</a></li> |
| 89 | <li class="toctree-l2"><a class="reference internal" href="../DCO.html">Developer’s Certificate of Origin 1.1</a></li> |
| 90 | </ul> |
| 91 | </li> |
| 92 | </ul> |
| 93 | <ul> |
| 94 | <li class="toctree-l1"><a class="reference internal" href="../general/index.html">General Topics</a><ul> |
| 95 | <li class="toctree-l2"><a class="reference internal" href="../general/urls.html">CodeIgniter URLs</a></li> |
| 96 | <li class="toctree-l2"><a class="reference internal" href="../general/controllers.html">Controllers</a></li> |
| 97 | <li class="toctree-l2"><a class="reference internal" href="../general/reserved_names.html">Reserved Names</a></li> |
| 98 | <li class="toctree-l2"><a class="reference internal" href="../general/views.html">Views</a></li> |
| 99 | <li class="toctree-l2"><a class="reference internal" href="../general/models.html">Models</a></li> |
| 100 | <li class="toctree-l2"><a class="reference internal" href="../general/helpers.html">Helpers</a></li> |
| 101 | <li class="toctree-l2"><a class="reference internal" href="../general/libraries.html">Using CodeIgniter Libraries</a></li> |
| 102 | <li class="toctree-l2"><a class="reference internal" href="../general/creating_libraries.html">Creating Libraries</a></li> |
| 103 | <li class="toctree-l2"><a class="reference internal" href="../general/drivers.html">Using CodeIgniter Drivers</a></li> |
| 104 | <li class="toctree-l2"><a class="reference internal" href="../general/creating_drivers.html">Creating Drivers</a></li> |
| 105 | <li class="toctree-l2"><a class="reference internal" href="../general/core_classes.html">Creating Core System Classes</a></li> |
| 106 | <li class="toctree-l2"><a class="reference internal" href="../general/ancillary_classes.html">Creating Ancillary Classes</a></li> |
| 107 | <li class="toctree-l2"><a class="reference internal" href="../general/hooks.html">Hooks - Extending the Framework Core</a></li> |
| 108 | <li class="toctree-l2"><a class="reference internal" href="../general/autoloader.html">Auto-loading Resources</a></li> |
| 109 | <li class="toctree-l2"><a class="reference internal" href="../general/common_functions.html">Common Functions</a></li> |
| 110 | <li class="toctree-l2"><a class="reference internal" href="../general/compatibility_functions.html">Compatibility Functions</a></li> |
| 111 | <li class="toctree-l2"><a class="reference internal" href="../general/routing.html">URI Routing</a></li> |
| 112 | <li class="toctree-l2"><a class="reference internal" href="../general/errors.html">Error Handling</a></li> |
| 113 | <li class="toctree-l2"><a class="reference internal" href="../general/caching.html">Caching</a></li> |
| 114 | <li class="toctree-l2"><a class="reference internal" href="../general/profiling.html">Profiling Your Application</a></li> |
| 115 | <li class="toctree-l2"><a class="reference internal" href="../general/cli.html">Running via the CLI</a></li> |
| 116 | <li class="toctree-l2"><a class="reference internal" href="../general/managing_apps.html">Managing your Applications</a></li> |
| 117 | <li class="toctree-l2"><a class="reference internal" href="../general/environments.html">Handling Multiple Environments</a></li> |
| 118 | <li class="toctree-l2"><a class="reference internal" href="../general/alternative_php.html">Alternate PHP Syntax for View Files</a></li> |
| 119 | <li class="toctree-l2"><a class="reference internal" href="../general/security.html">Security</a></li> |
| 120 | <li class="toctree-l2"><a class="reference internal" href="../general/styleguide.html">PHP Style Guide</a></li> |
| 121 | </ul> |
| 122 | </li> |
| 123 | </ul> |
| 124 | <ul class="current"> |
| 125 | <li class="toctree-l1 current"><a class="reference internal" href="index.html">Libraries</a><ul class="current"> |
| 126 | <li class="toctree-l2"><a class="reference internal" href="benchmark.html">Benchmarking Class</a></li> |
| 127 | <li class="toctree-l2"><a class="reference internal" href="caching.html">Caching Driver</a></li> |
| 128 | <li class="toctree-l2"><a class="reference internal" href="calendar.html">Calendaring Class</a></li> |
| 129 | <li class="toctree-l2"><a class="reference internal" href="cart.html">Shopping Cart Class</a></li> |
| 130 | <li class="toctree-l2"><a class="reference internal" href="config.html">Config Class</a></li> |
| 131 | <li class="toctree-l2"><a class="reference internal" href="email.html">Email Class</a></li> |
| 132 | <li class="toctree-l2"><a class="reference internal" href="encrypt.html">Encrypt Class</a></li> |
| 133 | <li class="toctree-l2"><a class="reference internal" href="encryption.html">Encryption Library</a></li> |
| 134 | <li class="toctree-l2"><a class="reference internal" href="file_uploading.html">File Uploading Class</a></li> |
| 135 | <li class="toctree-l2"><a class="reference internal" href="form_validation.html">Form Validation</a></li> |
| 136 | <li class="toctree-l2"><a class="reference internal" href="ftp.html">FTP Class</a></li> |
| 137 | <li class="toctree-l2 current"><a class="current reference internal" href="#">Image Manipulation Class</a></li> |
| 138 | <li class="toctree-l2"><a class="reference internal" href="input.html">Input Class</a></li> |
| 139 | <li class="toctree-l2"><a class="reference internal" href="javascript.html">Javascript Class</a></li> |
| 140 | <li class="toctree-l2"><a class="reference internal" href="language.html">Language Class</a></li> |
| 141 | <li class="toctree-l2"><a class="reference internal" href="loader.html">Loader Class</a></li> |
| 142 | <li class="toctree-l2"><a class="reference internal" href="migration.html">Migrations Class</a></li> |
| 143 | <li class="toctree-l2"><a class="reference internal" href="output.html">Output Class</a></li> |
| 144 | <li class="toctree-l2"><a class="reference internal" href="pagination.html">Pagination Class</a></li> |
| 145 | <li class="toctree-l2"><a class="reference internal" href="parser.html">Template Parser Class</a></li> |
| 146 | <li class="toctree-l2"><a class="reference internal" href="security.html">Security Class</a></li> |
| 147 | <li class="toctree-l2"><a class="reference internal" href="sessions.html">Session Library</a></li> |
| 148 | <li class="toctree-l2"><a class="reference internal" href="table.html">HTML Table Class</a></li> |
| 149 | <li class="toctree-l2"><a class="reference internal" href="trackback.html">Trackback Class</a></li> |
| 150 | <li class="toctree-l2"><a class="reference internal" href="typography.html">Typography Class</a></li> |
| 151 | <li class="toctree-l2"><a class="reference internal" href="unit_testing.html">Unit Testing Class</a></li> |
| 152 | <li class="toctree-l2"><a class="reference internal" href="uri.html">URI Class</a></li> |
| 153 | <li class="toctree-l2"><a class="reference internal" href="user_agent.html">User Agent Class</a></li> |
| 154 | <li class="toctree-l2"><a class="reference internal" href="xmlrpc.html">XML-RPC and XML-RPC Server Classes</a></li> |
| 155 | <li class="toctree-l2"><a class="reference internal" href="zip.html">Zip Encoding Class</a></li> |
| 156 | </ul> |
| 157 | </li> |
| 158 | </ul> |
| 159 | <ul> |
| 160 | <li class="toctree-l1"><a class="reference internal" href="../database/index.html">Database Reference</a><ul> |
| 161 | <li class="toctree-l2"><a class="reference internal" href="../database/examples.html">Quick Start: Usage Examples</a></li> |
| 162 | <li class="toctree-l2"><a class="reference internal" href="../database/configuration.html">Database Configuration</a></li> |
| 163 | <li class="toctree-l2"><a class="reference internal" href="../database/connecting.html">Connecting to a Database</a></li> |
| 164 | <li class="toctree-l2"><a class="reference internal" href="../database/queries.html">Running Queries</a></li> |
| 165 | <li class="toctree-l2"><a class="reference internal" href="../database/results.html">Generating Query Results</a></li> |
| 166 | <li class="toctree-l2"><a class="reference internal" href="../database/helpers.html">Query Helper Functions</a></li> |
| 167 | <li class="toctree-l2"><a class="reference internal" href="../database/query_builder.html">Query Builder Class</a></li> |
| 168 | <li class="toctree-l2"><a class="reference internal" href="../database/transactions.html">Transactions</a></li> |
| 169 | <li class="toctree-l2"><a class="reference internal" href="../database/metadata.html">Getting MetaData</a></li> |
| 170 | <li class="toctree-l2"><a class="reference internal" href="../database/call_function.html">Custom Function Calls</a></li> |
| 171 | <li class="toctree-l2"><a class="reference internal" href="../database/caching.html">Query Caching</a></li> |
| 172 | <li class="toctree-l2"><a class="reference internal" href="../database/forge.html">Database Manipulation with Database Forge</a></li> |
| 173 | <li class="toctree-l2"><a class="reference internal" href="../database/utilities.html">Database Utilities Class</a></li> |
| 174 | <li class="toctree-l2"><a class="reference internal" href="../database/db_driver_reference.html">Database Driver Reference</a></li> |
| 175 | </ul> |
| 176 | </li> |
| 177 | </ul> |
| 178 | <ul> |
| 179 | <li class="toctree-l1"><a class="reference internal" href="../helpers/index.html">Helpers</a><ul> |
| 180 | <li class="toctree-l2"><a class="reference internal" href="../helpers/array_helper.html">Array Helper</a></li> |
| 181 | <li class="toctree-l2"><a class="reference internal" href="../helpers/captcha_helper.html">CAPTCHA Helper</a></li> |
| 182 | <li class="toctree-l2"><a class="reference internal" href="../helpers/cookie_helper.html">Cookie Helper</a></li> |
| 183 | <li class="toctree-l2"><a class="reference internal" href="../helpers/date_helper.html">Date Helper</a></li> |
| 184 | <li class="toctree-l2"><a class="reference internal" href="../helpers/directory_helper.html">Directory Helper</a></li> |
| 185 | <li class="toctree-l2"><a class="reference internal" href="../helpers/download_helper.html">Download Helper</a></li> |
| 186 | <li class="toctree-l2"><a class="reference internal" href="../helpers/email_helper.html">Email Helper</a></li> |
| 187 | <li class="toctree-l2"><a class="reference internal" href="../helpers/file_helper.html">File Helper</a></li> |
| 188 | <li class="toctree-l2"><a class="reference internal" href="../helpers/form_helper.html">Form Helper</a></li> |
| 189 | <li class="toctree-l2"><a class="reference internal" href="../helpers/html_helper.html">HTML Helper</a></li> |
| 190 | <li class="toctree-l2"><a class="reference internal" href="../helpers/inflector_helper.html">Inflector Helper</a></li> |
| 191 | <li class="toctree-l2"><a class="reference internal" href="../helpers/language_helper.html">Language Helper</a></li> |
| 192 | <li class="toctree-l2"><a class="reference internal" href="../helpers/number_helper.html">Number Helper</a></li> |
| 193 | <li class="toctree-l2"><a class="reference internal" href="../helpers/path_helper.html">Path Helper</a></li> |
| 194 | <li class="toctree-l2"><a class="reference internal" href="../helpers/security_helper.html">Security Helper</a></li> |
| 195 | <li class="toctree-l2"><a class="reference internal" href="../helpers/smiley_helper.html">Smiley Helper</a></li> |
| 196 | <li class="toctree-l2"><a class="reference internal" href="../helpers/string_helper.html">String Helper</a></li> |
| 197 | <li class="toctree-l2"><a class="reference internal" href="../helpers/text_helper.html">Text Helper</a></li> |
| 198 | <li class="toctree-l2"><a class="reference internal" href="../helpers/typography_helper.html">Typography Helper</a></li> |
| 199 | <li class="toctree-l2"><a class="reference internal" href="../helpers/url_helper.html">URL Helper</a></li> |
| 200 | <li class="toctree-l2"><a class="reference internal" href="../helpers/xml_helper.html">XML Helper</a></li> |
| 201 | </ul> |
| 202 | </li> |
| 203 | </ul> |
| 204 | |
| 205 | </div> |
| 206 | |
| 207 | |
| 208 | </div> |
| 209 | </div> |
| 210 | <div id="nav2"> |
| 211 | <a href="#" id="openToc"> |
| 212 | <img src="data:image/jpeg;base64,/9j/4AAQSkZJRgABAgAAZABkAAD/7AARRHVja3kAAQAEAAAARgAA/+4ADkFkb2JlAGTAAAAAAf/bAIQABAMDAwMDBAMDBAYEAwQGBwUEBAUHCAYGBwYGCAoICQkJCQgKCgwMDAwMCgwMDQ0MDBERERERFBQUFBQUFBQUFAEEBQUIBwgPCgoPFA4ODhQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQU/8AAEQgAKwCaAwERAAIRAQMRAf/EAHsAAQAABwEBAAAAAAAAAAAAAAABAwQFBgcIAgkBAQAAAAAAAAAAAAAAAAAAAAAQAAEDAwICBwYEAgsAAAAAAAIBAwQAEQUSBiEHkROTVNQWGDFBUVIUCHEiMtOUFWGBobHRQlMkZIRVEQEAAAAAAAAAAAAAAAAAAAAA/9oADAMBAAIRAxEAPwDSC+ygkOOaUoKigUCgUCgUCgUCgUCgUCgUCgkuGguIP9FBMFb0Hqg7We+3jlmIqqYFf4ub+/QYlnOR/LqIBKGFUbf8qWv971BytQXXE7Y3Lnm3HsFhp2TaZJAdchRXpIgSpdEJWxJEW3xoKV7F5OMy7JkQn2o7D6w33XGjEAkoiqrJEqIiOIiKuhePCgqp22dyYyS3CyWHnQ5joG61HkRnmnTbaFSMhExRVQRRVJU9iUHjE7ez+fJ0MFipmUNhBV8YUd2SoIV9KkjQla9ltegttBdPLW4/qocL+UTfrMiHW4+P9M71shuyrqaHTcxsl7jegpsji8nh5ZwMvDfgTm0RTjSmjYdFCS6KoOIipdFunCgmNYTMv457MMY6U7iI6oMieDDhRm1VbIhuoOkbqtuK0Hpzb+eZcYZexUxt6UyUqK2cd0SdjtgrhOgijcgERUlJOCIl6CpgbP3blRI8XgMjNARAyKNDfeRBdFDBVUAXgQrqH4pxoJTu2NysY97LP4ac1io5q1InHFeGO24LnVKJuKOkSQ/yKir+rh7aCLG1dzypZQI2FnvTgccYOM3FeN0XWERXAUEFVQgQkUktdLpegm+Td3/Xli/L+S/mYNJIOF9G/wBeLKrZHFb0akG6W1WtQWSg3Dyg5e7V3fipE3O4/wCrktyzYA+ufas2LbZIlmnAT2kvuoN1wft95augilglX/tzP3qCu9O3LL/wV/i5v79BvmTADq14UGu91467Z6U9y0HzH/ncj/U/sT/CgynZG7I2NezpZGUjIycJkYkZSG+uQ81pbBNKLxJfjwoMqZ3/ALYHl35AJ7/cuwHcu5k7r1Q5pHetBjquqVVJWGxj9Zrtcl/Ggy3dHMvauR3HFZj5nHNxSyW5JISYDMoIwx8tFIGHZhPNaykGapr6rUAiicEoMG21lMRj8buPAz8xhJrr7uOeiPTCyAwXUaGR1mgozbTusOsFLEiJ7fbQa/h7gcjy2H3V6xppwDNtUSxCJIqp7valBuWVzJ22xuCROXNNZiJkMtms0DbjUkAZjzoDrTMd9dDRI44ZC2YsrYdKWP2WDT2S3N9dNdlRYrGMYc06IURXSYb0igrpWS485xVNS6nF4rwslkoMwnbpgZLB7bmt5uMweAhDEl4B5uSLzzqTnnyVpW2jaJHRMSIjdDiiotvy3DOE5rYTEbkl5yFn28k7JyG4c7AU2HtLH1uKfaiMPI40CdYbpNtmLdwTSn5rewLNld+7TLdeal4WarWBkbVKBjgdElMJJwAAY5fl4kB3b1fp4XvagsGS3FjJfLzDNtS8aeXx7LzT7TyzByQE5PccRGRC0ZRUDRV6y62vbjagzLmJzS2vuPK43JY6aP1TW6Jz+RIWyFtyC06y3EkiiinAo7YCqfq1AqqnGgsOH3lhZO8d1pmcpB8j5XIm9OYlBJSQ/FSS4427DKO0RC8AlcEMhFdViRR1WDWR5t3WXVuL1d106kG9vdeye2g60+1FDyW0shIcXVpyroXt8I8dfd+NB1vioAdWnD3UF1+gD4UFc6CEKpagxXN43rwJLUHz7yX2c8zokt9uHlsPIhA4aRnnHJTLptIS6CNsY7iASpxUUMkReGpfbQW0vtN5pitvrsN28rwtBD0nc0+/Yft5XhaB6TuaXfsP28rwtA9J3NPv2H7eV4Wgek7mn37D9vK8LQPSdzT79h+3leFoHpO5pd+w/byvC0D0nc0u/Yft5XhaB6TuaXfsP28rwtA9J3NLv2H7eV4Wgek7ml37D9vK8LQPSdzS79h+3leFoHpO5p9+w/byvC0E9r7Reazy2HIYVPxkS/CUHVn26cosxyv2g7h89LYmZSXOenvLEQ1YaQ222RATcQCP8rSGqqA8S02W2pQ6FhMoAIlqCtsnwoCpdKClejI4i3Sgtb+GBxVuNBSFt1pV/RQefLjPyUDy4z8lA8uM/JQPLjPyUDy4z8lA8uM/JQPLjPyUDy4z8lA8uM/JQPLjPyUDy4z8lA8utJ/koJ7WCbBU/LQXOPAFq1koK8B0pag90CggtBBf6qB0UDooHRQOigdFA6KB0UDooHRQOigdFA6KB0UDooI0EaBQf//Z" title="Toggle Table of Contents" alt="Toggle Table of Contents" /> |
| 213 | </a> |
| 214 | </div> |
| 215 | |
| 216 | <div class="wy-grid-for-nav"> |
| 217 | |
| 218 | |
| 219 | <nav data-toggle="wy-nav-shift" class="wy-nav-side"> |
| 220 | <div class="wy-side-nav-search"> |
| 221 | |
| 222 | <a href="../index.html" class="fa fa-home"> CodeIgniter</a> |
| 223 | |
| 224 | |
| 225 | <div role="search"> |
| 226 | <form id="rtd-search-form" class="wy-form" action="../search.html" method="get"> |
| 227 | <input type="text" name="q" placeholder="Search docs" /> |
| 228 | <input type="hidden" name="check_keywords" value="yes" /> |
| 229 | <input type="hidden" name="area" value="default" /> |
| 230 | </form> |
| 231 | </div> |
| 232 | </div> |
| 233 | |
| 234 | <div class="wy-menu wy-menu-vertical" data-spy="affix" role="navigation" aria-label="main navigation"> |
| 235 | |
| 236 | |
| 237 | |
| 238 | <ul> |
| 239 | <li class="toctree-l1"><a class="reference internal" href="../general/welcome.html">Welcome to CodeIgniter</a></li> |
| 240 | </ul> |
| 241 | <ul> |
| 242 | <li class="toctree-l1"><a class="reference internal" href="../installation/index.html">Installation Instructions</a><ul> |
| 243 | <li class="toctree-l2"><a class="reference internal" href="../installation/downloads.html">Downloading CodeIgniter</a></li> |
| 244 | <li class="toctree-l2"><a class="reference internal" href="../installation/index.html">Installation Instructions</a></li> |
| 245 | <li class="toctree-l2"><a class="reference internal" href="../installation/upgrading.html">Upgrading From a Previous Version</a></li> |
| 246 | <li class="toctree-l2"><a class="reference internal" href="../installation/troubleshooting.html">Troubleshooting</a></li> |
| 247 | </ul> |
| 248 | </li> |
| 249 | </ul> |
| 250 | <ul> |
| 251 | <li class="toctree-l1"><a class="reference internal" href="../overview/index.html">CodeIgniter Overview</a><ul> |
| 252 | <li class="toctree-l2"><a class="reference internal" href="../overview/getting_started.html">Getting Started</a></li> |
| 253 | <li class="toctree-l2"><a class="reference internal" href="../overview/at_a_glance.html">CodeIgniter at a Glance</a></li> |
| 254 | <li class="toctree-l2"><a class="reference internal" href="../overview/features.html">Supported Features</a></li> |
| 255 | <li class="toctree-l2"><a class="reference internal" href="../overview/appflow.html">Application Flow Chart</a></li> |
| 256 | <li class="toctree-l2"><a class="reference internal" href="../overview/mvc.html">Model-View-Controller</a></li> |
| 257 | <li class="toctree-l2"><a class="reference internal" href="../overview/goals.html">Architectural Goals</a></li> |
| 258 | </ul> |
| 259 | </li> |
| 260 | </ul> |
| 261 | <ul> |
| 262 | <li class="toctree-l1"><a class="reference internal" href="../tutorial/index.html">Tutorial</a><ul> |
| 263 | <li class="toctree-l2"><a class="reference internal" href="../tutorial/static_pages.html">Static pages</a></li> |
| 264 | <li class="toctree-l2"><a class="reference internal" href="../tutorial/news_section.html">News section</a></li> |
| 265 | <li class="toctree-l2"><a class="reference internal" href="../tutorial/create_news_items.html">Create news items</a></li> |
| 266 | <li class="toctree-l2"><a class="reference internal" href="../tutorial/conclusion.html">Conclusion</a></li> |
| 267 | </ul> |
| 268 | </li> |
| 269 | </ul> |
| 270 | <ul> |
| 271 | <li class="toctree-l1"><a class="reference internal" href="../contributing/index.html">Contributing to CodeIgniter</a><ul> |
| 272 | <li class="toctree-l2"><a class="reference internal" href="../documentation/index.html">Writing CodeIgniter Documentation</a></li> |
| 273 | <li class="toctree-l2"><a class="reference internal" href="../DCO.html">Developer’s Certificate of Origin 1.1</a></li> |
| 274 | </ul> |
| 275 | </li> |
| 276 | </ul> |
| 277 | <ul> |
| 278 | <li class="toctree-l1"><a class="reference internal" href="../general/index.html">General Topics</a><ul> |
| 279 | <li class="toctree-l2"><a class="reference internal" href="../general/urls.html">CodeIgniter URLs</a></li> |
| 280 | <li class="toctree-l2"><a class="reference internal" href="../general/controllers.html">Controllers</a></li> |
| 281 | <li class="toctree-l2"><a class="reference internal" href="../general/reserved_names.html">Reserved Names</a></li> |
| 282 | <li class="toctree-l2"><a class="reference internal" href="../general/views.html">Views</a></li> |
| 283 | <li class="toctree-l2"><a class="reference internal" href="../general/models.html">Models</a></li> |
| 284 | <li class="toctree-l2"><a class="reference internal" href="../general/helpers.html">Helpers</a></li> |
| 285 | <li class="toctree-l2"><a class="reference internal" href="../general/libraries.html">Using CodeIgniter Libraries</a></li> |
| 286 | <li class="toctree-l2"><a class="reference internal" href="../general/creating_libraries.html">Creating Libraries</a></li> |
| 287 | <li class="toctree-l2"><a class="reference internal" href="../general/drivers.html">Using CodeIgniter Drivers</a></li> |
| 288 | <li class="toctree-l2"><a class="reference internal" href="../general/creating_drivers.html">Creating Drivers</a></li> |
| 289 | <li class="toctree-l2"><a class="reference internal" href="../general/core_classes.html">Creating Core System Classes</a></li> |
| 290 | <li class="toctree-l2"><a class="reference internal" href="../general/ancillary_classes.html">Creating Ancillary Classes</a></li> |
| 291 | <li class="toctree-l2"><a class="reference internal" href="../general/hooks.html">Hooks - Extending the Framework Core</a></li> |
| 292 | <li class="toctree-l2"><a class="reference internal" href="../general/autoloader.html">Auto-loading Resources</a></li> |
| 293 | <li class="toctree-l2"><a class="reference internal" href="../general/common_functions.html">Common Functions</a></li> |
| 294 | <li class="toctree-l2"><a class="reference internal" href="../general/compatibility_functions.html">Compatibility Functions</a></li> |
| 295 | <li class="toctree-l2"><a class="reference internal" href="../general/routing.html">URI Routing</a></li> |
| 296 | <li class="toctree-l2"><a class="reference internal" href="../general/errors.html">Error Handling</a></li> |
| 297 | <li class="toctree-l2"><a class="reference internal" href="../general/caching.html">Caching</a></li> |
| 298 | <li class="toctree-l2"><a class="reference internal" href="../general/profiling.html">Profiling Your Application</a></li> |
| 299 | <li class="toctree-l2"><a class="reference internal" href="../general/cli.html">Running via the CLI</a></li> |
| 300 | <li class="toctree-l2"><a class="reference internal" href="../general/managing_apps.html">Managing your Applications</a></li> |
| 301 | <li class="toctree-l2"><a class="reference internal" href="../general/environments.html">Handling Multiple Environments</a></li> |
| 302 | <li class="toctree-l2"><a class="reference internal" href="../general/alternative_php.html">Alternate PHP Syntax for View Files</a></li> |
| 303 | <li class="toctree-l2"><a class="reference internal" href="../general/security.html">Security</a></li> |
| 304 | <li class="toctree-l2"><a class="reference internal" href="../general/styleguide.html">PHP Style Guide</a></li> |
| 305 | </ul> |
| 306 | </li> |
| 307 | </ul> |
| 308 | <ul class="current"> |
| 309 | <li class="toctree-l1 current"><a class="reference internal" href="index.html">Libraries</a><ul class="current"> |
| 310 | <li class="toctree-l2"><a class="reference internal" href="benchmark.html">Benchmarking Class</a></li> |
| 311 | <li class="toctree-l2"><a class="reference internal" href="caching.html">Caching Driver</a></li> |
| 312 | <li class="toctree-l2"><a class="reference internal" href="calendar.html">Calendaring Class</a></li> |
| 313 | <li class="toctree-l2"><a class="reference internal" href="cart.html">Shopping Cart Class</a></li> |
| 314 | <li class="toctree-l2"><a class="reference internal" href="config.html">Config Class</a></li> |
| 315 | <li class="toctree-l2"><a class="reference internal" href="email.html">Email Class</a></li> |
| 316 | <li class="toctree-l2"><a class="reference internal" href="encrypt.html">Encrypt Class</a></li> |
| 317 | <li class="toctree-l2"><a class="reference internal" href="encryption.html">Encryption Library</a></li> |
| 318 | <li class="toctree-l2"><a class="reference internal" href="file_uploading.html">File Uploading Class</a></li> |
| 319 | <li class="toctree-l2"><a class="reference internal" href="form_validation.html">Form Validation</a></li> |
| 320 | <li class="toctree-l2"><a class="reference internal" href="ftp.html">FTP Class</a></li> |
| 321 | <li class="toctree-l2 current"><a class="current reference internal" href="#">Image Manipulation Class</a></li> |
| 322 | <li class="toctree-l2"><a class="reference internal" href="input.html">Input Class</a></li> |
| 323 | <li class="toctree-l2"><a class="reference internal" href="javascript.html">Javascript Class</a></li> |
| 324 | <li class="toctree-l2"><a class="reference internal" href="language.html">Language Class</a></li> |
| 325 | <li class="toctree-l2"><a class="reference internal" href="loader.html">Loader Class</a></li> |
| 326 | <li class="toctree-l2"><a class="reference internal" href="migration.html">Migrations Class</a></li> |
| 327 | <li class="toctree-l2"><a class="reference internal" href="output.html">Output Class</a></li> |
| 328 | <li class="toctree-l2"><a class="reference internal" href="pagination.html">Pagination Class</a></li> |
| 329 | <li class="toctree-l2"><a class="reference internal" href="parser.html">Template Parser Class</a></li> |
| 330 | <li class="toctree-l2"><a class="reference internal" href="security.html">Security Class</a></li> |
| 331 | <li class="toctree-l2"><a class="reference internal" href="sessions.html">Session Library</a></li> |
| 332 | <li class="toctree-l2"><a class="reference internal" href="table.html">HTML Table Class</a></li> |
| 333 | <li class="toctree-l2"><a class="reference internal" href="trackback.html">Trackback Class</a></li> |
| 334 | <li class="toctree-l2"><a class="reference internal" href="typography.html">Typography Class</a></li> |
| 335 | <li class="toctree-l2"><a class="reference internal" href="unit_testing.html">Unit Testing Class</a></li> |
| 336 | <li class="toctree-l2"><a class="reference internal" href="uri.html">URI Class</a></li> |
| 337 | <li class="toctree-l2"><a class="reference internal" href="user_agent.html">User Agent Class</a></li> |
| 338 | <li class="toctree-l2"><a class="reference internal" href="xmlrpc.html">XML-RPC and XML-RPC Server Classes</a></li> |
| 339 | <li class="toctree-l2"><a class="reference internal" href="zip.html">Zip Encoding Class</a></li> |
| 340 | </ul> |
| 341 | </li> |
| 342 | </ul> |
| 343 | <ul> |
| 344 | <li class="toctree-l1"><a class="reference internal" href="../database/index.html">Database Reference</a><ul> |
| 345 | <li class="toctree-l2"><a class="reference internal" href="../database/examples.html">Quick Start: Usage Examples</a></li> |
| 346 | <li class="toctree-l2"><a class="reference internal" href="../database/configuration.html">Database Configuration</a></li> |
| 347 | <li class="toctree-l2"><a class="reference internal" href="../database/connecting.html">Connecting to a Database</a></li> |
| 348 | <li class="toctree-l2"><a class="reference internal" href="../database/queries.html">Running Queries</a></li> |
| 349 | <li class="toctree-l2"><a class="reference internal" href="../database/results.html">Generating Query Results</a></li> |
| 350 | <li class="toctree-l2"><a class="reference internal" href="../database/helpers.html">Query Helper Functions</a></li> |
| 351 | <li class="toctree-l2"><a class="reference internal" href="../database/query_builder.html">Query Builder Class</a></li> |
| 352 | <li class="toctree-l2"><a class="reference internal" href="../database/transactions.html">Transactions</a></li> |
| 353 | <li class="toctree-l2"><a class="reference internal" href="../database/metadata.html">Getting MetaData</a></li> |
| 354 | <li class="toctree-l2"><a class="reference internal" href="../database/call_function.html">Custom Function Calls</a></li> |
| 355 | <li class="toctree-l2"><a class="reference internal" href="../database/caching.html">Query Caching</a></li> |
| 356 | <li class="toctree-l2"><a class="reference internal" href="../database/forge.html">Database Manipulation with Database Forge</a></li> |
| 357 | <li class="toctree-l2"><a class="reference internal" href="../database/utilities.html">Database Utilities Class</a></li> |
| 358 | <li class="toctree-l2"><a class="reference internal" href="../database/db_driver_reference.html">Database Driver Reference</a></li> |
| 359 | </ul> |
| 360 | </li> |
| 361 | </ul> |
| 362 | <ul> |
| 363 | <li class="toctree-l1"><a class="reference internal" href="../helpers/index.html">Helpers</a><ul> |
| 364 | <li class="toctree-l2"><a class="reference internal" href="../helpers/array_helper.html">Array Helper</a></li> |
| 365 | <li class="toctree-l2"><a class="reference internal" href="../helpers/captcha_helper.html">CAPTCHA Helper</a></li> |
| 366 | <li class="toctree-l2"><a class="reference internal" href="../helpers/cookie_helper.html">Cookie Helper</a></li> |
| 367 | <li class="toctree-l2"><a class="reference internal" href="../helpers/date_helper.html">Date Helper</a></li> |
| 368 | <li class="toctree-l2"><a class="reference internal" href="../helpers/directory_helper.html">Directory Helper</a></li> |
| 369 | <li class="toctree-l2"><a class="reference internal" href="../helpers/download_helper.html">Download Helper</a></li> |
| 370 | <li class="toctree-l2"><a class="reference internal" href="../helpers/email_helper.html">Email Helper</a></li> |
| 371 | <li class="toctree-l2"><a class="reference internal" href="../helpers/file_helper.html">File Helper</a></li> |
| 372 | <li class="toctree-l2"><a class="reference internal" href="../helpers/form_helper.html">Form Helper</a></li> |
| 373 | <li class="toctree-l2"><a class="reference internal" href="../helpers/html_helper.html">HTML Helper</a></li> |
| 374 | <li class="toctree-l2"><a class="reference internal" href="../helpers/inflector_helper.html">Inflector Helper</a></li> |
| 375 | <li class="toctree-l2"><a class="reference internal" href="../helpers/language_helper.html">Language Helper</a></li> |
| 376 | <li class="toctree-l2"><a class="reference internal" href="../helpers/number_helper.html">Number Helper</a></li> |
| 377 | <li class="toctree-l2"><a class="reference internal" href="../helpers/path_helper.html">Path Helper</a></li> |
| 378 | <li class="toctree-l2"><a class="reference internal" href="../helpers/security_helper.html">Security Helper</a></li> |
| 379 | <li class="toctree-l2"><a class="reference internal" href="../helpers/smiley_helper.html">Smiley Helper</a></li> |
| 380 | <li class="toctree-l2"><a class="reference internal" href="../helpers/string_helper.html">String Helper</a></li> |
| 381 | <li class="toctree-l2"><a class="reference internal" href="../helpers/text_helper.html">Text Helper</a></li> |
| 382 | <li class="toctree-l2"><a class="reference internal" href="../helpers/typography_helper.html">Typography Helper</a></li> |
| 383 | <li class="toctree-l2"><a class="reference internal" href="../helpers/url_helper.html">URL Helper</a></li> |
| 384 | <li class="toctree-l2"><a class="reference internal" href="../helpers/xml_helper.html">XML Helper</a></li> |
| 385 | </ul> |
| 386 | </li> |
| 387 | </ul> |
| 388 | |
| 389 | |
| 390 | |
| 391 | </div> |
| 392 | |
| 393 | </nav> |
| 394 | |
| 395 | <section data-toggle="wy-nav-shift" class="wy-nav-content-wrap"> |
| 396 | |
| 397 | |
| 398 | <nav class="wy-nav-top" role="navigation" aria-label="top navigation"> |
| 399 | <i data-toggle="wy-nav-top" class="fa fa-bars"></i> |
| 400 | <a href="../index.html">CodeIgniter</a> |
| 401 | </nav> |
| 402 | |
| 403 | |
| 404 | |
| 405 | <div class="wy-nav-content"> |
| 406 | <div class="rst-content"> |
| 407 | <div role="navigation" aria-label="breadcrumbs navigation"> |
| 408 | <ul class="wy-breadcrumbs"> |
| 409 | <li><a href="../index.html">Docs</a> »</li> |
| 410 | |
| 411 | <li><a href="index.html">Libraries</a> »</li> |
| 412 | |
| 413 | <li>Image Manipulation Class</li> |
| 414 | <li class="wy-breadcrumbs-aside"> |
| 415 | |
| 416 | </li> |
| 417 | <div style="float:right;margin-left:5px;" id="closeMe"> |
| 418 | <img title="Classic Layout" alt="classic layout" src="data:image/gif;base64,R0lGODlhFAAUAJEAAAAAADMzM////wAAACH5BAUUAAIALAAAAAAUABQAAAImlI+py+0PU5gRBRDM3DxbWoXis42X13USOLauUIqnlsaH/eY6UwAAOw==" /> |
| 419 | </div> |
| 420 | </ul> |
| 421 | <hr/> |
| 422 | </div> |
| 423 | <div role="main" class="document"> |
| 424 | |
| 425 | <div class="section" id="image-manipulation-class"> |
| 426 | <h1>Image Manipulation Class<a class="headerlink" href="#image-manipulation-class" title="Permalink to this headline">¶</a></h1> |
| 427 | <p>CodeIgniter’s Image Manipulation class lets you perform the following |
| 428 | actions:</p> |
| 429 | <ul class="simple"> |
| 430 | <li>Image Resizing</li> |
| 431 | <li>Thumbnail Creation</li> |
| 432 | <li>Image Cropping</li> |
| 433 | <li>Image Rotating</li> |
| 434 | <li>Image Watermarking</li> |
| 435 | </ul> |
| 436 | <p>All three major image libraries are supported: GD/GD2, NetPBM, and |
| 437 | ImageMagick</p> |
| 438 | <div class="admonition note"> |
| 439 | <p class="first admonition-title">Note</p> |
| 440 | <p class="last">Watermarking is only available using the GD/GD2 library. In |
| 441 | addition, even though other libraries are supported, GD is required in |
| 442 | order for the script to calculate the image properties. The image |
| 443 | processing, however, will be performed with the library you specify.</p> |
| 444 | </div> |
| 445 | <div class="contents local topic" id="contents"> |
| 446 | <ul class="simple"> |
| 447 | <li><a class="reference internal" href="#initializing-the-class" id="id1">Initializing the Class</a><ul> |
| 448 | <li><a class="reference internal" href="#processing-an-image" id="id2">Processing an Image</a></li> |
| 449 | <li><a class="reference internal" href="#processing-methods" id="id3">Processing Methods</a></li> |
| 450 | <li><a class="reference internal" href="#preferences" id="id4">Preferences</a></li> |
| 451 | <li><a class="reference internal" href="#setting-preferences-in-a-config-file" id="id5">Setting preferences in a config file</a></li> |
| 452 | </ul> |
| 453 | </li> |
| 454 | <li><a class="reference internal" href="#image-watermarking" id="id6">Image Watermarking</a><ul> |
| 455 | <li><a class="reference internal" href="#two-types-of-watermarking" id="id7">Two Types of Watermarking</a></li> |
| 456 | <li><a class="reference internal" href="#watermarking-an-image" id="id8">Watermarking an Image</a></li> |
| 457 | <li><a class="reference internal" href="#watermarking-preferences" id="id9">Watermarking Preferences</a><ul> |
| 458 | <li><a class="reference internal" href="#text-preferences" id="id10">Text Preferences</a></li> |
| 459 | <li><a class="reference internal" href="#overlay-preferences" id="id11">Overlay Preferences</a></li> |
| 460 | </ul> |
| 461 | </li> |
| 462 | </ul> |
| 463 | </li> |
| 464 | <li><a class="reference internal" href="#class-reference" id="id12">Class Reference</a></li> |
| 465 | </ul> |
| 466 | </div> |
| 467 | <div class="custom-index container"></div><div class="section" id="initializing-the-class"> |
| 468 | <h2><a class="toc-backref" href="#id1">Initializing the Class</a><a class="headerlink" href="#initializing-the-class" title="Permalink to this headline">¶</a></h2> |
| 469 | <p>Like most other classes in CodeIgniter, the image class is initialized |
| 470 | in your controller using the $this->load->library function:</p> |
| 471 | <div class="highlight-ci"><div class="highlight"><pre><span></span><span class="nv">$this</span><span class="o">-></span><span class="na">load</span><span class="o">-></span><span class="na">library</span><span class="p">(</span><span class="s1">'image_lib'</span><span class="p">);</span> |
| 472 | </pre></div> |
| 473 | </div> |
| 474 | <p>Once the library is loaded it will be ready for use. The image library |
| 475 | object you will use to call all functions is: <code class="docutils literal"><span class="pre">$this->image_lib</span></code></p> |
| 476 | <div class="section" id="processing-an-image"> |
| 477 | <h3><a class="toc-backref" href="#id2">Processing an Image</a><a class="headerlink" href="#processing-an-image" title="Permalink to this headline">¶</a></h3> |
| 478 | <p>Regardless of the type of processing you would like to perform |
| 479 | (resizing, cropping, rotation, or watermarking), the general process is |
| 480 | identical. You will set some preferences corresponding to the action you |
| 481 | intend to perform, then call one of four available processing functions. |
| 482 | For example, to create an image thumbnail you’ll do this:</p> |
| 483 | <div class="highlight-ci"><div class="highlight"><pre><span></span><span class="nv">$config</span><span class="p">[</span><span class="s1">'image_library'</span><span class="p">]</span> <span class="o">=</span> <span class="s1">'gd2'</span><span class="p">;</span> |
| 484 | <span class="nv">$config</span><span class="p">[</span><span class="s1">'source_image'</span><span class="p">]</span> <span class="o">=</span> <span class="s1">'/path/to/image/mypic.jpg'</span><span class="p">;</span> |
| 485 | <span class="nv">$config</span><span class="p">[</span><span class="s1">'create_thumb'</span><span class="p">]</span> <span class="o">=</span> <span class="k">TRUE</span><span class="p">;</span> |
| 486 | <span class="nv">$config</span><span class="p">[</span><span class="s1">'maintain_ratio'</span><span class="p">]</span> <span class="o">=</span> <span class="k">TRUE</span><span class="p">;</span> |
| 487 | <span class="nv">$config</span><span class="p">[</span><span class="s1">'width'</span><span class="p">]</span> <span class="o">=</span> <span class="mi">75</span><span class="p">;</span> |
| 488 | <span class="nv">$config</span><span class="p">[</span><span class="s1">'height'</span><span class="p">]</span> <span class="o">=</span> <span class="mi">50</span><span class="p">;</span> |
| 489 | |
| 490 | <span class="nv">$this</span><span class="o">-></span><span class="na">load</span><span class="o">-></span><span class="na">library</span><span class="p">(</span><span class="s1">'image_lib'</span><span class="p">,</span> <span class="nv">$config</span><span class="p">);</span> |
| 491 | |
| 492 | <span class="nv">$this</span><span class="o">-></span><span class="na">image_lib</span><span class="o">-></span><span class="na">resize</span><span class="p">();</span> |
| 493 | </pre></div> |
| 494 | </div> |
| 495 | <p>The above code tells the image_resize function to look for an image |
| 496 | called <em>mypic.jpg</em> located in the source_image folder, then create a |
| 497 | thumbnail that is 75 X 50 pixels using the GD2 image_library. Since the |
| 498 | maintain_ratio option is enabled, the thumb will be as close to the |
| 499 | target width and height as possible while preserving the original aspect |
| 500 | ratio. The thumbnail will be called <em>mypic_thumb.jpg</em> and located at |
| 501 | the same level as <em>source_image</em>.</p> |
| 502 | <div class="admonition note"> |
| 503 | <p class="first admonition-title">Note</p> |
| 504 | <p class="last">In order for the image class to be allowed to do any |
| 505 | processing, the folder containing the image files must have write |
| 506 | permissions.</p> |
| 507 | </div> |
| 508 | <div class="admonition note"> |
| 509 | <p class="first admonition-title">Note</p> |
| 510 | <p class="last">Image processing can require a considerable amount of server |
| 511 | memory for some operations. If you are experiencing out of memory errors |
| 512 | while processing images you may need to limit their maximum size, and/or |
| 513 | adjust PHP memory limits.</p> |
| 514 | </div> |
| 515 | </div> |
| 516 | <div class="section" id="processing-methods"> |
| 517 | <h3><a class="toc-backref" href="#id3">Processing Methods</a><a class="headerlink" href="#processing-methods" title="Permalink to this headline">¶</a></h3> |
| 518 | <p>There are four available processing methods:</p> |
| 519 | <ul class="simple"> |
| 520 | <li>$this->image_lib->resize()</li> |
| 521 | <li>$this->image_lib->crop()</li> |
| 522 | <li>$this->image_lib->rotate()</li> |
| 523 | <li>$this->image_lib->watermark()</li> |
| 524 | </ul> |
| 525 | <p>These methods return boolean TRUE upon success and FALSE for failure. |
| 526 | If they fail you can retrieve the error message using this function:</p> |
| 527 | <div class="highlight-ci"><div class="highlight"><pre><span></span><span class="k">echo</span> <span class="nv">$this</span><span class="o">-></span><span class="na">image_lib</span><span class="o">-></span><span class="na">display_errors</span><span class="p">();</span> |
| 528 | </pre></div> |
| 529 | </div> |
| 530 | <p>A good practice is to use the processing function conditionally, showing an |
| 531 | error upon failure, like this:</p> |
| 532 | <div class="highlight-ci"><div class="highlight"><pre><span></span><span class="k">if</span> <span class="p">(</span> <span class="o">!</span> <span class="nv">$this</span><span class="o">-></span><span class="na">image_lib</span><span class="o">-></span><span class="na">resize</span><span class="p">())</span> |
| 533 | <span class="p">{</span> |
| 534 | <span class="k">echo</span> <span class="nv">$this</span><span class="o">-></span><span class="na">image_lib</span><span class="o">-></span><span class="na">display_errors</span><span class="p">();</span> |
| 535 | <span class="p">}</span> |
| 536 | </pre></div> |
| 537 | </div> |
| 538 | <div class="admonition note"> |
| 539 | <p class="first admonition-title">Note</p> |
| 540 | <p>You can optionally specify the HTML formatting to be applied to |
| 541 | the errors, by submitting the opening/closing tags in the function, |
| 542 | like this:</p> |
| 543 | <div class="last highlight-ci"><div class="highlight"><pre><span></span><span class="nv">$this</span><span class="o">-></span><span class="na">image_lib</span><span class="o">-></span><span class="na">display_errors</span><span class="p">(</span><span class="s1">'<p>'</span><span class="p">,</span> <span class="s1">'</p>'</span><span class="p">);</span> |
| 544 | </pre></div> |
| 545 | </div> |
| 546 | </div> |
| 547 | </div> |
| 548 | <div class="section" id="preferences"> |
| 549 | <span id="processing-preferences"></span><h3><a class="toc-backref" href="#id4">Preferences</a><a class="headerlink" href="#preferences" title="Permalink to this headline">¶</a></h3> |
| 550 | <p>The preferences described below allow you to tailor the image processing |
| 551 | to suit your needs.</p> |
| 552 | <p>Note that not all preferences are available for every function. For |
| 553 | example, the x/y axis preferences are only available for image cropping. |
| 554 | Likewise, the width and height preferences have no effect on cropping. |
| 555 | The “availability” column indicates which functions support a given |
| 556 | preference.</p> |
| 557 | <p>Availability Legend:</p> |
| 558 | <ul class="simple"> |
| 559 | <li>R - Image Resizing</li> |
| 560 | <li>C - Image Cropping</li> |
| 561 | <li>X - Image Rotation</li> |
| 562 | <li>W - Image Watermarking</li> |
| 563 | </ul> |
| 564 | <table border="1" class="docutils"> |
| 565 | <colgroup> |
| 566 | <col width="14%" /> |
| 567 | <col width="14%" /> |
| 568 | <col width="19%" /> |
| 569 | <col width="45%" /> |
| 570 | <col width="8%" /> |
| 571 | </colgroup> |
| 572 | <thead valign="bottom"> |
| 573 | <tr class="row-odd"><th class="head">Preference</th> |
| 574 | <th class="head">Default Value</th> |
| 575 | <th class="head">Options</th> |
| 576 | <th class="head">Description</th> |
| 577 | <th class="head">Availability</th> |
| 578 | </tr> |
| 579 | </thead> |
| 580 | <tbody valign="top"> |
| 581 | <tr class="row-even"><td><strong>image_library</strong></td> |
| 582 | <td>GD2</td> |
| 583 | <td>GD, GD2, ImageMagick, NetPBM</td> |
| 584 | <td>Sets the image library to be used.</td> |
| 585 | <td>R, C, X, W</td> |
| 586 | </tr> |
| 587 | <tr class="row-odd"><td><strong>library_path</strong></td> |
| 588 | <td>None</td> |
| 589 | <td>None</td> |
| 590 | <td>Sets the server path to your ImageMagick or NetPBM library. If you use |
| 591 | either of those libraries you must supply the path.</td> |
| 592 | <td>R, C, X |
| 593 | R, C, S, W</td> |
| 594 | </tr> |
| 595 | <tr class="row-even"><td><strong>source_image</strong></td> |
| 596 | <td>None</td> |
| 597 | <td>None</td> |
| 598 | <td>Sets the source image name/path. The path must be a relative or absolute |
| 599 | server path, not a URL.</td> |
| 600 | <td> </td> |
| 601 | </tr> |
| 602 | <tr class="row-odd"><td><strong>dynamic_output</strong></td> |
| 603 | <td>FALSE</td> |
| 604 | <td>TRUE/FALSE (boolean)</td> |
| 605 | <td>Determines whether the new image file should be written to disk or |
| 606 | generated dynamically. Note: If you choose the dynamic setting, only one |
| 607 | image can be shown at a time, and it can’t be positioned on the page. It |
| 608 | simply outputs the raw image dynamically to your browser, along with |
| 609 | image headers.</td> |
| 610 | <td>R, C, X, W</td> |
| 611 | </tr> |
| 612 | <tr class="row-even"><td><strong>file_permissions</strong></td> |
| 613 | <td>0644</td> |
| 614 | <td>(integer)</td> |
| 615 | <td>File system permissions to apply on the resulting image file, |
| 616 | writing it to the disk. WARNING: Use octal integer notation!</td> |
| 617 | <td>R, C, X, W</td> |
| 618 | </tr> |
| 619 | <tr class="row-odd"><td><strong>quality</strong></td> |
| 620 | <td>90%</td> |
| 621 | <td>1 - 100%</td> |
| 622 | <td>Sets the quality of the image. The higher the quality the larger the |
| 623 | file size.</td> |
| 624 | <td>R, C, X, W</td> |
| 625 | </tr> |
| 626 | <tr class="row-even"><td><strong>new_image</strong></td> |
| 627 | <td>None</td> |
| 628 | <td>None</td> |
| 629 | <td>Sets the destination image name/path. You’ll use this preference when |
| 630 | creating an image copy. The path must be a relative or absolute server |
| 631 | path, not a URL.</td> |
| 632 | <td>R, C, X, W</td> |
| 633 | </tr> |
| 634 | <tr class="row-odd"><td><strong>width</strong></td> |
| 635 | <td>None</td> |
| 636 | <td>None</td> |
| 637 | <td>Sets the width you would like the image set to.</td> |
| 638 | <td>R, C</td> |
| 639 | </tr> |
| 640 | <tr class="row-even"><td><strong>height</strong></td> |
| 641 | <td>None</td> |
| 642 | <td>None</td> |
| 643 | <td>Sets the height you would like the image set to.</td> |
| 644 | <td>R, C</td> |
| 645 | </tr> |
| 646 | <tr class="row-odd"><td><strong>create_thumb</strong></td> |
| 647 | <td>FALSE</td> |
| 648 | <td>TRUE/FALSE (boolean)</td> |
| 649 | <td>Tells the image processing function to create a thumb.</td> |
| 650 | <td>R</td> |
| 651 | </tr> |
| 652 | <tr class="row-even"><td><strong>thumb_marker</strong></td> |
| 653 | <td>_thumb</td> |
| 654 | <td>None</td> |
| 655 | <td>Specifies the thumbnail indicator. It will be inserted just before the |
| 656 | file extension, so mypic.jpg would become mypic_thumb.jpg</td> |
| 657 | <td>R</td> |
| 658 | </tr> |
| 659 | <tr class="row-odd"><td><strong>maintain_ratio</strong></td> |
| 660 | <td>TRUE</td> |
| 661 | <td>TRUE/FALSE (boolean)</td> |
| 662 | <td>Specifies whether to maintain the original aspect ratio when resizing or |
| 663 | use hard values.</td> |
| 664 | <td>R, C</td> |
| 665 | </tr> |
| 666 | <tr class="row-even"><td><strong>master_dim</strong></td> |
| 667 | <td>auto</td> |
| 668 | <td>auto, width, height</td> |
| 669 | <td>Specifies what to use as the master axis when resizing or creating |
| 670 | thumbs. For example, let’s say you want to resize an image to 100 X 75 |
| 671 | pixels. If the source image size does not allow perfect resizing to |
| 672 | those dimensions, this setting determines which axis should be used as |
| 673 | the hard value. “auto” sets the axis automatically based on whether the |
| 674 | image is taller than wider, or vice versa.</td> |
| 675 | <td>R</td> |
| 676 | </tr> |
| 677 | <tr class="row-odd"><td><strong>rotation_angle</strong></td> |
| 678 | <td>None</td> |
| 679 | <td>90, 180, 270, vrt, hor</td> |
| 680 | <td>Specifies the angle of rotation when rotating images. Note that PHP |
| 681 | rotates counter-clockwise, so a 90 degree rotation to the right must be |
| 682 | specified as 270.</td> |
| 683 | <td>X</td> |
| 684 | </tr> |
| 685 | <tr class="row-even"><td><strong>x_axis</strong></td> |
| 686 | <td>None</td> |
| 687 | <td>None</td> |
| 688 | <td>Sets the X coordinate in pixels for image cropping. For example, a |
| 689 | setting of 30 will crop an image 30 pixels from the left.</td> |
| 690 | <td>C</td> |
| 691 | </tr> |
| 692 | <tr class="row-odd"><td><strong>y_axis</strong></td> |
| 693 | <td>None</td> |
| 694 | <td>None</td> |
| 695 | <td>Sets the Y coordinate in pixels for image cropping. For example, a |
| 696 | setting of 30 will crop an image 30 pixels from the top.</td> |
| 697 | <td>C</td> |
| 698 | </tr> |
| 699 | </tbody> |
| 700 | </table> |
| 701 | </div> |
| 702 | <div class="section" id="setting-preferences-in-a-config-file"> |
| 703 | <h3><a class="toc-backref" href="#id5">Setting preferences in a config file</a><a class="headerlink" href="#setting-preferences-in-a-config-file" title="Permalink to this headline">¶</a></h3> |
| 704 | <p>If you prefer not to set preferences using the above method, you can |
| 705 | instead put them into a config file. Simply create a new file called |
| 706 | image_lib.php, add the $config array in that file. Then save the file |
| 707 | in <em>config/image_lib.php</em> and it will be used automatically. You will |
| 708 | NOT need to use the <code class="docutils literal"><span class="pre">$this->image_lib->initialize()</span></code> method if you save |
| 709 | your preferences in a config file.</p> |
| 710 | </div> |
| 711 | </div> |
| 712 | <div class="section" id="image-watermarking"> |
| 713 | <h2><a class="toc-backref" href="#id6">Image Watermarking</a><a class="headerlink" href="#image-watermarking" title="Permalink to this headline">¶</a></h2> |
| 714 | <p>The Watermarking feature requires the GD/GD2 library.</p> |
| 715 | <div class="section" id="two-types-of-watermarking"> |
| 716 | <h3><a class="toc-backref" href="#id7">Two Types of Watermarking</a><a class="headerlink" href="#two-types-of-watermarking" title="Permalink to this headline">¶</a></h3> |
| 717 | <p>There are two types of watermarking that you can use:</p> |
| 718 | <ul class="simple"> |
| 719 | <li><strong>Text</strong>: The watermark message will be generated using text, either |
| 720 | with a True Type font that you specify, or using the native text |
| 721 | output that the GD library supports. If you use the True Type version |
| 722 | your GD installation must be compiled with True Type support (most |
| 723 | are, but not all).</li> |
| 724 | <li><strong>Overlay</strong>: The watermark message will be generated by overlaying an |
| 725 | image (usually a transparent PNG or GIF) containing your watermark |
| 726 | over the source image.</li> |
| 727 | </ul> |
| 728 | </div> |
| 729 | <div class="section" id="watermarking-an-image"> |
| 730 | <span id="watermarking"></span><h3><a class="toc-backref" href="#id8">Watermarking an Image</a><a class="headerlink" href="#watermarking-an-image" title="Permalink to this headline">¶</a></h3> |
| 731 | <p>Just as with the other methods (resizing, cropping, and rotating) the |
| 732 | general process for watermarking involves setting the preferences |
| 733 | corresponding to the action you intend to perform, then calling the |
| 734 | watermark function. Here is an example:</p> |
| 735 | <div class="highlight-ci"><div class="highlight"><pre><span></span><span class="nv">$config</span><span class="p">[</span><span class="s1">'source_image'</span><span class="p">]</span> <span class="o">=</span> <span class="s1">'/path/to/image/mypic.jpg'</span><span class="p">;</span> |
| 736 | <span class="nv">$config</span><span class="p">[</span><span class="s1">'wm_text'</span><span class="p">]</span> <span class="o">=</span> <span class="s1">'Copyright 2006 - John Doe'</span><span class="p">;</span> |
| 737 | <span class="nv">$config</span><span class="p">[</span><span class="s1">'wm_type'</span><span class="p">]</span> <span class="o">=</span> <span class="s1">'text'</span><span class="p">;</span> |
| 738 | <span class="nv">$config</span><span class="p">[</span><span class="s1">'wm_font_path'</span><span class="p">]</span> <span class="o">=</span> <span class="s1">'./system/fonts/texb.ttf'</span><span class="p">;</span> |
| 739 | <span class="nv">$config</span><span class="p">[</span><span class="s1">'wm_font_size'</span><span class="p">]</span> <span class="o">=</span> <span class="s1">'16'</span><span class="p">;</span> |
| 740 | <span class="nv">$config</span><span class="p">[</span><span class="s1">'wm_font_color'</span><span class="p">]</span> <span class="o">=</span> <span class="s1">'ffffff'</span><span class="p">;</span> |
| 741 | <span class="nv">$config</span><span class="p">[</span><span class="s1">'wm_vrt_alignment'</span><span class="p">]</span> <span class="o">=</span> <span class="s1">'bottom'</span><span class="p">;</span> |
| 742 | <span class="nv">$config</span><span class="p">[</span><span class="s1">'wm_hor_alignment'</span><span class="p">]</span> <span class="o">=</span> <span class="s1">'center'</span><span class="p">;</span> |
| 743 | <span class="nv">$config</span><span class="p">[</span><span class="s1">'wm_padding'</span><span class="p">]</span> <span class="o">=</span> <span class="s1">'20'</span><span class="p">;</span> |
| 744 | |
| 745 | <span class="nv">$this</span><span class="o">-></span><span class="na">image_lib</span><span class="o">-></span><span class="na">initialize</span><span class="p">(</span><span class="nv">$config</span><span class="p">);</span> |
| 746 | |
| 747 | <span class="nv">$this</span><span class="o">-></span><span class="na">image_lib</span><span class="o">-></span><span class="na">watermark</span><span class="p">();</span> |
| 748 | </pre></div> |
| 749 | </div> |
| 750 | <p>The above example will use a 16 pixel True Type font to create the text |
| 751 | “Copyright 2006 - John Doe”. The watermark will be positioned at the |
| 752 | bottom/center of the image, 20 pixels from the bottom of the image.</p> |
| 753 | <div class="admonition note"> |
| 754 | <p class="first admonition-title">Note</p> |
| 755 | <p class="last">In order for the image class to be allowed to do any |
| 756 | processing, the image file must have “write” file permissions |
| 757 | For example, 777.</p> |
| 758 | </div> |
| 759 | </div> |
| 760 | <div class="section" id="watermarking-preferences"> |
| 761 | <h3><a class="toc-backref" href="#id9">Watermarking Preferences</a><a class="headerlink" href="#watermarking-preferences" title="Permalink to this headline">¶</a></h3> |
| 762 | <p>This table shows the preferences that are available for both types of |
| 763 | watermarking (text or overlay)</p> |
| 764 | <table border="1" class="docutils"> |
| 765 | <colgroup> |
| 766 | <col width="17%" /> |
| 767 | <col width="14%" /> |
| 768 | <col width="17%" /> |
| 769 | <col width="53%" /> |
| 770 | </colgroup> |
| 771 | <thead valign="bottom"> |
| 772 | <tr class="row-odd"><th class="head">Preference</th> |
| 773 | <th class="head">Default Value</th> |
| 774 | <th class="head">Options</th> |
| 775 | <th class="head">Description</th> |
| 776 | </tr> |
| 777 | </thead> |
| 778 | <tbody valign="top"> |
| 779 | <tr class="row-even"><td><strong>wm_type</strong></td> |
| 780 | <td>text</td> |
| 781 | <td>text, overlay</td> |
| 782 | <td>Sets the type of watermarking that should be used.</td> |
| 783 | </tr> |
| 784 | <tr class="row-odd"><td><strong>source_image</strong></td> |
| 785 | <td>None</td> |
| 786 | <td>None</td> |
| 787 | <td>Sets the source image name/path. The path must be a relative or absolute |
| 788 | server path, not a URL.</td> |
| 789 | </tr> |
| 790 | <tr class="row-even"><td><strong>dynamic_output</strong></td> |
| 791 | <td>FALSE</td> |
| 792 | <td>TRUE/FALSE (boolean)</td> |
| 793 | <td>Determines whether the new image file should be written to disk or |
| 794 | generated dynamically. Note: If you choose the dynamic setting, only one |
| 795 | image can be shown at a time, and it can’t be positioned on the page. It |
| 796 | simply outputs the raw image dynamically to your browser, along with |
| 797 | image headers.</td> |
| 798 | </tr> |
| 799 | <tr class="row-odd"><td><strong>quality</strong></td> |
| 800 | <td>90%</td> |
| 801 | <td>1 - 100%</td> |
| 802 | <td>Sets the quality of the image. The higher the quality the larger the |
| 803 | file size.</td> |
| 804 | </tr> |
| 805 | <tr class="row-even"><td><strong>wm_padding</strong></td> |
| 806 | <td>None</td> |
| 807 | <td>A number</td> |
| 808 | <td>The amount of padding, set in pixels, that will be applied to the |
| 809 | watermark to set it away from the edge of your images.</td> |
| 810 | </tr> |
| 811 | <tr class="row-odd"><td><strong>wm_vrt_alignment</strong></td> |
| 812 | <td>bottom</td> |
| 813 | <td>top, middle, bottom</td> |
| 814 | <td>Sets the vertical alignment for the watermark image.</td> |
| 815 | </tr> |
| 816 | <tr class="row-even"><td><strong>wm_hor_alignment</strong></td> |
| 817 | <td>center</td> |
| 818 | <td>left, center, right</td> |
| 819 | <td>Sets the horizontal alignment for the watermark image.</td> |
| 820 | </tr> |
| 821 | <tr class="row-odd"><td><strong>wm_hor_offset</strong></td> |
| 822 | <td>None</td> |
| 823 | <td>None</td> |
| 824 | <td>You may specify a horizontal offset (in pixels) to apply to the |
| 825 | watermark position. The offset normally moves the watermark to the |
| 826 | right, except if you have your alignment set to “right” then your offset |
| 827 | value will move the watermark toward the left of the image.</td> |
| 828 | </tr> |
| 829 | <tr class="row-even"><td><strong>wm_vrt_offset</strong></td> |
| 830 | <td>None</td> |
| 831 | <td>None</td> |
| 832 | <td>You may specify a vertical offset (in pixels) to apply to the watermark |
| 833 | position. The offset normally moves the watermark down, except if you |
| 834 | have your alignment set to “bottom” then your offset value will move the |
| 835 | watermark toward the top of the image.</td> |
| 836 | </tr> |
| 837 | </tbody> |
| 838 | </table> |
| 839 | <div class="section" id="text-preferences"> |
| 840 | <h4><a class="toc-backref" href="#id10">Text Preferences</a><a class="headerlink" href="#text-preferences" title="Permalink to this headline">¶</a></h4> |
| 841 | <p>This table shows the preferences that are available for the text type of |
| 842 | watermarking.</p> |
| 843 | <table border="1" class="docutils"> |
| 844 | <colgroup> |
| 845 | <col width="17%" /> |
| 846 | <col width="14%" /> |
| 847 | <col width="14%" /> |
| 848 | <col width="55%" /> |
| 849 | </colgroup> |
| 850 | <thead valign="bottom"> |
| 851 | <tr class="row-odd"><th class="head">Preference</th> |
| 852 | <th class="head">Default Value</th> |
| 853 | <th class="head">Options</th> |
| 854 | <th class="head">Description</th> |
| 855 | </tr> |
| 856 | </thead> |
| 857 | <tbody valign="top"> |
| 858 | <tr class="row-even"><td><strong>wm_text</strong></td> |
| 859 | <td>None</td> |
| 860 | <td>None</td> |
| 861 | <td>The text you would like shown as the watermark. Typically this will be a |
| 862 | copyright notice.</td> |
| 863 | </tr> |
| 864 | <tr class="row-odd"><td><strong>wm_font_path</strong></td> |
| 865 | <td>None</td> |
| 866 | <td>None</td> |
| 867 | <td>The server path to the True Type Font you would like to use. If you do |
| 868 | not use this option, the native GD font will be used.</td> |
| 869 | </tr> |
| 870 | <tr class="row-even"><td><strong>wm_font_size</strong></td> |
| 871 | <td>16</td> |
| 872 | <td>None</td> |
| 873 | <td>The size of the text. Note: If you are not using the True Type option |
| 874 | above, the number is set using a range of 1 - 5. Otherwise, you can use |
| 875 | any valid pixel size for the font you’re using.</td> |
| 876 | </tr> |
| 877 | <tr class="row-odd"><td><strong>wm_font_color</strong></td> |
| 878 | <td>ffffff</td> |
| 879 | <td>None</td> |
| 880 | <td>The font color, specified in hex. Both the full 6-length (ie, 993300) and |
| 881 | the short three character abbreviated version (ie, fff) are supported.</td> |
| 882 | </tr> |
| 883 | <tr class="row-even"><td><strong>wm_shadow_color</strong></td> |
| 884 | <td>None</td> |
| 885 | <td>None</td> |
| 886 | <td>The color of the drop shadow, specified in hex. If you leave this blank |
| 887 | a drop shadow will not be used. Both the full 6-length (ie, 993300) and |
| 888 | the short three character abbreviated version (ie, fff) are supported.</td> |
| 889 | </tr> |
| 890 | <tr class="row-odd"><td><strong>wm_shadow_distance</strong></td> |
| 891 | <td>3</td> |
| 892 | <td>None</td> |
| 893 | <td>The distance (in pixels) from the font that the drop shadow should |
| 894 | appear.</td> |
| 895 | </tr> |
| 896 | </tbody> |
| 897 | </table> |
| 898 | </div> |
| 899 | <div class="section" id="overlay-preferences"> |
| 900 | <h4><a class="toc-backref" href="#id11">Overlay Preferences</a><a class="headerlink" href="#overlay-preferences" title="Permalink to this headline">¶</a></h4> |
| 901 | <p>This table shows the preferences that are available for the overlay type |
| 902 | of watermarking.</p> |
| 903 | <table border="1" class="docutils"> |
| 904 | <colgroup> |
| 905 | <col width="17%" /> |
| 906 | <col width="14%" /> |
| 907 | <col width="14%" /> |
| 908 | <col width="55%" /> |
| 909 | </colgroup> |
| 910 | <thead valign="bottom"> |
| 911 | <tr class="row-odd"><th class="head">Preference</th> |
| 912 | <th class="head">Default Value</th> |
| 913 | <th class="head">Options</th> |
| 914 | <th class="head">Description</th> |
| 915 | </tr> |
| 916 | </thead> |
| 917 | <tbody valign="top"> |
| 918 | <tr class="row-even"><td><strong>wm_overlay_path</strong></td> |
| 919 | <td>None</td> |
| 920 | <td>None</td> |
| 921 | <td>The server path to the image you wish to use as your watermark. Required |
| 922 | only if you are using the overlay method.</td> |
| 923 | </tr> |
| 924 | <tr class="row-odd"><td><strong>wm_opacity</strong></td> |
| 925 | <td>50</td> |
| 926 | <td>1 - 100</td> |
| 927 | <td>Image opacity. You may specify the opacity (i.e. transparency) of your |
| 928 | watermark image. This allows the watermark to be faint and not |
| 929 | completely obscure the details from the original image behind it. A 50% |
| 930 | opacity is typical.</td> |
| 931 | </tr> |
| 932 | <tr class="row-even"><td><strong>wm_x_transp</strong></td> |
| 933 | <td>4</td> |
| 934 | <td>A number</td> |
| 935 | <td>If your watermark image is a PNG or GIF image, you may specify a color |
| 936 | on the image to be “transparent”. This setting (along with the next) |
| 937 | will allow you to specify that color. This works by specifying the “X” |
| 938 | and “Y” coordinate pixel (measured from the upper left) within the image |
| 939 | that corresponds to a pixel representative of the color you want to be |
| 940 | transparent.</td> |
| 941 | </tr> |
| 942 | <tr class="row-odd"><td><strong>wm_y_transp</strong></td> |
| 943 | <td>4</td> |
| 944 | <td>A number</td> |
| 945 | <td>Along with the previous setting, this allows you to specify the |
| 946 | coordinate to a pixel representative of the color you want to be |
| 947 | transparent.</td> |
| 948 | </tr> |
| 949 | </tbody> |
| 950 | </table> |
| 951 | </div> |
| 952 | </div> |
| 953 | </div> |
| 954 | <div class="section" id="class-reference"> |
| 955 | <h2><a class="toc-backref" href="#id12">Class Reference</a><a class="headerlink" href="#class-reference" title="Permalink to this headline">¶</a></h2> |
| 956 | <dl class="class"> |
| 957 | <dt id="CI_Image_lib"> |
| 958 | <em class="property">class </em><code class="descname">CI_Image_lib</code><a class="headerlink" href="#CI_Image_lib" title="Permalink to this definition">¶</a></dt> |
| 959 | <dd><dl class="method"> |
| 960 | <dt id="CI_Image_lib::initialize"> |
| 961 | <code class="descname">initialize</code><span class="sig-paren">(</span><span class="optional">[</span><em>$props = array()</em><span class="optional">]</span><span class="sig-paren">)</span><a class="headerlink" href="#CI_Image_lib::initialize" title="Permalink to this definition">¶</a></dt> |
| 962 | <dd><table class="docutils field-list" frame="void" rules="none"> |
| 963 | <col class="field-name" /> |
| 964 | <col class="field-body" /> |
| 965 | <tbody valign="top"> |
| 966 | <tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><ul class="first simple"> |
| 967 | <li><strong>$props</strong> (<em>array</em>) – Image processing preferences</li> |
| 968 | </ul> |
| 969 | </td> |
| 970 | </tr> |
| 971 | <tr class="field-even field"><th class="field-name">Returns:</th><td class="field-body"><p class="first">TRUE on success, FALSE in case of invalid settings</p> |
| 972 | </td> |
| 973 | </tr> |
| 974 | <tr class="field-odd field"><th class="field-name">Return type:</th><td class="field-body"><p class="first last">bool</p> |
| 975 | </td> |
| 976 | </tr> |
| 977 | </tbody> |
| 978 | </table> |
| 979 | <p>Initializes the class for processing an image.</p> |
| 980 | </dd></dl> |
| 981 | |
| 982 | <dl class="method"> |
| 983 | <dt id="CI_Image_lib::resize"> |
| 984 | <code class="descname">resize</code><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="headerlink" href="#CI_Image_lib::resize" title="Permalink to this definition">¶</a></dt> |
| 985 | <dd><table class="docutils field-list" frame="void" rules="none"> |
| 986 | <col class="field-name" /> |
| 987 | <col class="field-body" /> |
| 988 | <tbody valign="top"> |
| 989 | <tr class="field-odd field"><th class="field-name">Returns:</th><td class="field-body">TRUE on success, FALSE on failure</td> |
| 990 | </tr> |
| 991 | <tr class="field-even field"><th class="field-name">Return type:</th><td class="field-body">bool</td> |
| 992 | </tr> |
| 993 | </tbody> |
| 994 | </table> |
| 995 | <p>The image resizing method lets you resize the original image, create a |
| 996 | copy (with or without resizing), or create a thumbnail image.</p> |
| 997 | <p>For practical purposes there is no difference between creating a copy |
| 998 | and creating a thumbnail except a thumb will have the thumbnail marker |
| 999 | as part of the name (i.e. mypic_thumb.jpg).</p> |
| 1000 | <p>All preferences listed in the <a class="reference internal" href="#processing-preferences"><span class="std std-ref">Preferences</span></a> table are available for this |
| 1001 | method except these three: <em>rotation_angle</em>, <em>x_axis</em> and <em>y_axis</em>.</p> |
| 1002 | <p><strong>Creating a Thumbnail</strong></p> |
| 1003 | <p>The resizing method will create a thumbnail file (and preserve the |
| 1004 | original) if you set this preference to TRUE:</p> |
| 1005 | <div class="highlight-ci"><div class="highlight"><pre><span></span><span class="nv">$config</span><span class="p">[</span><span class="s1">'create_thumb'</span><span class="p">]</span> <span class="o">=</span> <span class="k">TRUE</span><span class="p">;</span> |
| 1006 | </pre></div> |
| 1007 | </div> |
| 1008 | <p>This single preference determines whether a thumbnail is created or not.</p> |
| 1009 | <p><strong>Creating a Copy</strong></p> |
| 1010 | <p>The resizing method will create a copy of the image file (and preserve |
| 1011 | the original) if you set a path and/or a new filename using this |
| 1012 | preference:</p> |
| 1013 | <div class="highlight-ci"><div class="highlight"><pre><span></span><span class="nv">$config</span><span class="p">[</span><span class="s1">'new_image'</span><span class="p">]</span> <span class="o">=</span> <span class="s1">'/path/to/new_image.jpg'</span><span class="p">;</span> |
| 1014 | </pre></div> |
| 1015 | </div> |
| 1016 | <p>Notes regarding this preference:</p> |
| 1017 | <ul class="simple"> |
| 1018 | <li>If only the new image name is specified it will be placed in the same |
| 1019 | folder as the original</li> |
| 1020 | <li>If only the path is specified, the new image will be placed in the |
| 1021 | destination with the same name as the original.</li> |
| 1022 | <li>If both the path and image name are specified it will placed in its |
| 1023 | own destination and given the new name.</li> |
| 1024 | </ul> |
| 1025 | <p><strong>Resizing the Original Image</strong></p> |
| 1026 | <p>If neither of the two preferences listed above (create_thumb, and |
| 1027 | new_image) are used, the resizing method will instead target the |
| 1028 | original image for processing.</p> |
| 1029 | </dd></dl> |
| 1030 | |
| 1031 | <dl class="method"> |
| 1032 | <dt id="CI_Image_lib::crop"> |
| 1033 | <code class="descname">crop</code><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="headerlink" href="#CI_Image_lib::crop" title="Permalink to this definition">¶</a></dt> |
| 1034 | <dd><table class="docutils field-list" frame="void" rules="none"> |
| 1035 | <col class="field-name" /> |
| 1036 | <col class="field-body" /> |
| 1037 | <tbody valign="top"> |
| 1038 | <tr class="field-odd field"><th class="field-name">Returns:</th><td class="field-body">TRUE on success, FALSE on failure</td> |
| 1039 | </tr> |
| 1040 | <tr class="field-even field"><th class="field-name">Return type:</th><td class="field-body">bool</td> |
| 1041 | </tr> |
| 1042 | </tbody> |
| 1043 | </table> |
| 1044 | <p>The cropping method works nearly identically to the resizing function |
| 1045 | except it requires that you set preferences for the X and Y axis (in |
| 1046 | pixels) specifying where to crop, like this:</p> |
| 1047 | <div class="highlight-ci"><div class="highlight"><pre><span></span><span class="nv">$config</span><span class="p">[</span><span class="s1">'x_axis'</span><span class="p">]</span> <span class="o">=</span> <span class="mi">100</span><span class="p">;</span> |
| 1048 | <span class="nv">$config</span><span class="p">[</span><span class="s1">'y_axis'</span><span class="p">]</span> <span class="o">=</span> <span class="mi">40</span><span class="p">;</span> |
| 1049 | </pre></div> |
| 1050 | </div> |
| 1051 | <p>All preferences listed in the <a class="reference internal" href="#processing-preferences"><span class="std std-ref">Preferences</span></a> table are available for this |
| 1052 | method except these: <em>rotation_angle</em>, <em>create_thumb</em> and <em>new_image</em>.</p> |
| 1053 | <p>Here’s an example showing how you might crop an image:</p> |
| 1054 | <div class="highlight-ci"><div class="highlight"><pre><span></span><span class="nv">$config</span><span class="p">[</span><span class="s1">'image_library'</span><span class="p">]</span> <span class="o">=</span> <span class="s1">'imagemagick'</span><span class="p">;</span> |
| 1055 | <span class="nv">$config</span><span class="p">[</span><span class="s1">'library_path'</span><span class="p">]</span> <span class="o">=</span> <span class="s1">'/usr/X11R6/bin/'</span><span class="p">;</span> |
| 1056 | <span class="nv">$config</span><span class="p">[</span><span class="s1">'source_image'</span><span class="p">]</span> <span class="o">=</span> <span class="s1">'/path/to/image/mypic.jpg'</span><span class="p">;</span> |
| 1057 | <span class="nv">$config</span><span class="p">[</span><span class="s1">'x_axis'</span><span class="p">]</span> <span class="o">=</span> <span class="mi">100</span><span class="p">;</span> |
| 1058 | <span class="nv">$config</span><span class="p">[</span><span class="s1">'y_axis'</span><span class="p">]</span> <span class="o">=</span> <span class="mi">60</span><span class="p">;</span> |
| 1059 | |
| 1060 | <span class="nv">$this</span><span class="o">-></span><span class="na">image_lib</span><span class="o">-></span><span class="na">initialize</span><span class="p">(</span><span class="nv">$config</span><span class="p">);</span> |
| 1061 | |
| 1062 | <span class="k">if</span> <span class="p">(</span> <span class="o">!</span> <span class="nv">$this</span><span class="o">-></span><span class="na">image_lib</span><span class="o">-></span><span class="na">crop</span><span class="p">())</span> |
| 1063 | <span class="p">{</span> |
| 1064 | <span class="k">echo</span> <span class="nv">$this</span><span class="o">-></span><span class="na">image_lib</span><span class="o">-></span><span class="na">display_errors</span><span class="p">();</span> |
| 1065 | <span class="p">}</span> |
| 1066 | </pre></div> |
| 1067 | </div> |
| 1068 | <div class="admonition note"> |
| 1069 | <p class="first admonition-title">Note</p> |
| 1070 | <p class="last">Without a visual interface it is difficult to crop images, so this |
| 1071 | method is not very useful unless you intend to build such an |
| 1072 | interface. That’s exactly what we did using for the photo gallery module |
| 1073 | in ExpressionEngine, the CMS we develop. We added a JavaScript UI that |
| 1074 | lets the cropping area be selected.</p> |
| 1075 | </div> |
| 1076 | </dd></dl> |
| 1077 | |
| 1078 | <dl class="method"> |
| 1079 | <dt id="CI_Image_lib::rotate"> |
| 1080 | <code class="descname">rotate</code><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="headerlink" href="#CI_Image_lib::rotate" title="Permalink to this definition">¶</a></dt> |
| 1081 | <dd><table class="docutils field-list" frame="void" rules="none"> |
| 1082 | <col class="field-name" /> |
| 1083 | <col class="field-body" /> |
| 1084 | <tbody valign="top"> |
| 1085 | <tr class="field-odd field"><th class="field-name">Returns:</th><td class="field-body">TRUE on success, FALSE on failure</td> |
| 1086 | </tr> |
| 1087 | <tr class="field-even field"><th class="field-name">Return type:</th><td class="field-body">bool</td> |
| 1088 | </tr> |
| 1089 | </tbody> |
| 1090 | </table> |
| 1091 | <p>The image rotation method requires that the angle of rotation be set |
| 1092 | via its preference:</p> |
| 1093 | <div class="highlight-ci"><div class="highlight"><pre><span></span><span class="nv">$config</span><span class="p">[</span><span class="s1">'rotation_angle'</span><span class="p">]</span> <span class="o">=</span> <span class="s1">'90'</span><span class="p">;</span> |
| 1094 | </pre></div> |
| 1095 | </div> |
| 1096 | <p>There are 5 rotation options:</p> |
| 1097 | <ol class="arabic simple"> |
| 1098 | <li>90 - rotates counter-clockwise by 90 degrees.</li> |
| 1099 | <li>180 - rotates counter-clockwise by 180 degrees.</li> |
| 1100 | <li>270 - rotates counter-clockwise by 270 degrees.</li> |
| 1101 | <li>hor - flips the image horizontally.</li> |
| 1102 | <li>vrt - flips the image vertically.</li> |
| 1103 | </ol> |
| 1104 | <p>Here’s an example showing how you might rotate an image:</p> |
| 1105 | <div class="highlight-ci"><div class="highlight"><pre><span></span><span class="nv">$config</span><span class="p">[</span><span class="s1">'image_library'</span><span class="p">]</span> <span class="o">=</span> <span class="s1">'netpbm'</span><span class="p">;</span> |
| 1106 | <span class="nv">$config</span><span class="p">[</span><span class="s1">'library_path'</span><span class="p">]</span> <span class="o">=</span> <span class="s1">'/usr/bin/'</span><span class="p">;</span> |
| 1107 | <span class="nv">$config</span><span class="p">[</span><span class="s1">'source_image'</span><span class="p">]</span> <span class="o">=</span> <span class="s1">'/path/to/image/mypic.jpg'</span><span class="p">;</span> |
| 1108 | <span class="nv">$config</span><span class="p">[</span><span class="s1">'rotation_angle'</span><span class="p">]</span> <span class="o">=</span> <span class="s1">'hor'</span><span class="p">;</span> |
| 1109 | |
| 1110 | <span class="nv">$this</span><span class="o">-></span><span class="na">image_lib</span><span class="o">-></span><span class="na">initialize</span><span class="p">(</span><span class="nv">$config</span><span class="p">);</span> |
| 1111 | |
| 1112 | <span class="k">if</span> <span class="p">(</span> <span class="o">!</span> <span class="nv">$this</span><span class="o">-></span><span class="na">image_lib</span><span class="o">-></span><span class="na">rotate</span><span class="p">())</span> |
| 1113 | <span class="p">{</span> |
| 1114 | <span class="k">echo</span> <span class="nv">$this</span><span class="o">-></span><span class="na">image_lib</span><span class="o">-></span><span class="na">display_errors</span><span class="p">();</span> |
| 1115 | <span class="p">}</span> |
| 1116 | </pre></div> |
| 1117 | </div> |
| 1118 | </dd></dl> |
| 1119 | |
| 1120 | <dl class="method"> |
| 1121 | <dt id="CI_Image_lib::watermark"> |
| 1122 | <code class="descname">watermark</code><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="headerlink" href="#CI_Image_lib::watermark" title="Permalink to this definition">¶</a></dt> |
| 1123 | <dd><table class="docutils field-list" frame="void" rules="none"> |
| 1124 | <col class="field-name" /> |
| 1125 | <col class="field-body" /> |
| 1126 | <tbody valign="top"> |
| 1127 | <tr class="field-odd field"><th class="field-name">Returns:</th><td class="field-body">TRUE on success, FALSE on failure</td> |
| 1128 | </tr> |
| 1129 | <tr class="field-even field"><th class="field-name">Return type:</th><td class="field-body">bool</td> |
| 1130 | </tr> |
| 1131 | </tbody> |
| 1132 | </table> |
| 1133 | <p>Creates a watermark over an image, please refer to the <a class="reference internal" href="#watermarking"><span class="std std-ref">Watermarking an Image</span></a> |
| 1134 | section for more info.</p> |
| 1135 | </dd></dl> |
| 1136 | |
| 1137 | <dl class="method"> |
| 1138 | <dt id="CI_Image_lib::clear"> |
| 1139 | <code class="descname">clear</code><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="headerlink" href="#CI_Image_lib::clear" title="Permalink to this definition">¶</a></dt> |
| 1140 | <dd><table class="docutils field-list" frame="void" rules="none"> |
| 1141 | <col class="field-name" /> |
| 1142 | <col class="field-body" /> |
| 1143 | <tbody valign="top"> |
| 1144 | <tr class="field-odd field"><th class="field-name">Return type:</th><td class="field-body">void</td> |
| 1145 | </tr> |
| 1146 | </tbody> |
| 1147 | </table> |
| 1148 | <p>The clear method resets all of the values used when processing an |
| 1149 | image. You will want to call this if you are processing images in a |
| 1150 | loop.</p> |
| 1151 | <div class="highlight-ci"><div class="highlight"><pre><span></span><span class="nv">$this</span><span class="o">-></span><span class="na">image_lib</span><span class="o">-></span><span class="na">clear</span><span class="p">();</span> |
| 1152 | </pre></div> |
| 1153 | </div> |
| 1154 | </dd></dl> |
| 1155 | |
| 1156 | <dl class="method"> |
| 1157 | <dt id="CI_Image_lib::display_errors"> |
| 1158 | <code class="descname">display_errors</code><span class="sig-paren">(</span><span class="optional">[</span><em>$open = '<p></em><span class="optional">[</span>, <em>$close = '</p>'</em><span class="optional">]</span><span class="optional">]</span><span class="sig-paren">)</span><a class="headerlink" href="#CI_Image_lib::display_errors" title="Permalink to this definition">¶</a></dt> |
| 1159 | <dd><table class="docutils field-list" frame="void" rules="none"> |
| 1160 | <col class="field-name" /> |
| 1161 | <col class="field-body" /> |
| 1162 | <tbody valign="top"> |
| 1163 | <tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><ul class="first simple"> |
| 1164 | <li><strong>$open</strong> (<em>string</em>) – Error message opening tag</li> |
| 1165 | <li><strong>$close</strong> (<em>string</em>) – Error message closing tag</li> |
| 1166 | </ul> |
| 1167 | </td> |
| 1168 | </tr> |
| 1169 | <tr class="field-even field"><th class="field-name">Returns:</th><td class="field-body"><p class="first">Error messages</p> |
| 1170 | </td> |
| 1171 | </tr> |
| 1172 | <tr class="field-odd field"><th class="field-name">Return type:</th><td class="field-body"><p class="first last">string</p> |
| 1173 | </td> |
| 1174 | </tr> |
| 1175 | </tbody> |
| 1176 | </table> |
| 1177 | <p>Returns all detected errors formatted as a string.</p> |
| 1178 | <div class="highlight-ci"><div class="highlight"><pre><span></span><span class="k">echo</span> <span class="nv">$this</span><span class="o">-></span><span class="na">image_lib</span><span class="o">-></span><span class="na">display_errors</span><span class="p">();</span> |
| 1179 | </pre></div> |
| 1180 | </div> |
| 1181 | </dd></dl> |
| 1182 | |
| 1183 | </dd></dl> |
| 1184 | |
| 1185 | </div> |
| 1186 | </div> |
| 1187 | |
| 1188 | |
| 1189 | </div> |
| 1190 | <footer> |
| 1191 | |
| 1192 | <div class="rst-footer-buttons" role="navigation" aria-label="footer navigation"> |
| 1193 | |
| 1194 | <a href="input.html" class="btn btn-neutral float-right" title="Input Class">Next <span class="fa fa-arrow-circle-right"></span></a> |
| 1195 | |
| 1196 | |
| 1197 | <a href="ftp.html" class="btn btn-neutral" title="FTP Class"><span class="fa fa-arrow-circle-left"></span> Previous</a> |
| 1198 | |
| 1199 | </div> |
| 1200 | |
| 1201 | |
| 1202 | <hr/> |
| 1203 | |
| 1204 | <div role="contentinfo"> |
| 1205 | <p> |
| 1206 | © Copyright 2014 - 2019, British Columbia Institute of Technology. |
| 1207 | Last updated on Jan 16, 2019. |
| 1208 | </p> |
| 1209 | </div> |
| 1210 | |
| 1211 | Built with <a href="http://sphinx-doc.org/">Sphinx</a> using a <a href="https://github.com/snide/sphinx_rtd_theme">theme</a> provided by <a href="https://readthedocs.org">Read the Docs</a>. |
| 1212 | |
| 1213 | </footer> |
| 1214 | </div> |
| 1215 | </div> |
| 1216 | |
| 1217 | </section> |
| 1218 | |
| 1219 | </div> |
| 1220 | |
| 1221 | |
| 1222 | |
| 1223 | |
| 1224 | |
| 1225 | <script type="text/javascript"> |
| 1226 | var DOCUMENTATION_OPTIONS = { |
| 1227 | URL_ROOT:'../', |
| 1228 | VERSION:'3.1.10', |
| 1229 | COLLAPSE_INDEX:false, |
| 1230 | FILE_SUFFIX:'.html', |
| 1231 | HAS_SOURCE: false |
| 1232 | }; |
| 1233 | </script> |
| 1234 | <script type="text/javascript" src="../_static/jquery.js"></script> |
| 1235 | <script type="text/javascript" src="../_static/underscore.js"></script> |
| 1236 | <script type="text/javascript" src="../_static/doctools.js"></script> |
| 1237 | |
| 1238 | |
| 1239 | |
| 1240 | |
| 1241 | |
| 1242 | <script type="text/javascript" src="../_static/js/theme.js"></script> |
| 1243 | |
| 1244 | |
| 1245 | |
| 1246 | |
| 1247 | <script type="text/javascript"> |
| 1248 | jQuery(function () { |
| 1249 | SphinxRtdTheme.StickyNav.enable(); |
| 1250 | }); |
| 1251 | </script> |
| 1252 | |
| 1253 | |
| 1254 | </body> |
| 1255 | </html> |