File tree Expand file tree Collapse file tree
user_guide_src/source/installation Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -240,6 +240,7 @@ Upgrading Libraries
240240 upgrade_encryption
241241 upgrade_file_upload
242242 upgrade_html_tables
243+ upgrade_images
243244 upgrade_localization
244245 upgrade_migrations
245246 upgrade_pagination
Original file line number Diff line number Diff line change 1+ Upgrade Image Manipulation Class
2+ ################################
3+
4+ .. contents ::
5+ :local:
6+ :depth: 2
7+
8+ Documentations
9+ ==============
10+
11+ - `Image Manipulation Class Documentation CodeIgniter 3.X <https://www.codeigniter.com/userguide3/libraries/image_lib.html >`_
12+ - :doc: `Image Manipulation Class Documentation CodeIgniter 4.X <../libraries/images >`
13+
14+ What has been changed
15+ =====================
16+ - The preferences passed to the constructor or ``initialize() `` method in CI3
17+ have been changed to be specified in the new methods in CI4.
18+ - Some preferences like ``create_thumb `` are removed.
19+ - In CI4, the ``save() `` method must be called to save the manipulated image.
20+ - The ``display_errors() `` has been removed, and an exception will be thrown
21+ if an error occurs.
22+
23+ Upgrade Guide
24+ =============
25+ 1. Within your class change the ``$this->load->library('image_lib'); `` to
26+ ``$image = \Config\Services::image(); ``.
27+ 2. Change the preferences passed to the constructor or ``initialize() `` method
28+ to be specified in the corresponding methods.
29+ 3. Call the ``save() `` method to save the file.
30+
31+ Code Example
32+ ============
33+
34+ CodeIgniter Version 3.x
35+ ------------------------
36+
37+ .. literalinclude :: upgrade_images/ci3sample/001.php
38+
39+ CodeIgniter Version 4.x
40+ -----------------------
41+
42+ .. literalinclude :: upgrade_images/001.php
Original file line number Diff line number Diff line change 1+ <?php
2+
3+ $ image = \Config \Services::image ();
4+
5+ $ image
6+ ->withFile ('/path/to/image/mypic.jpg ' )
7+ ->resize (75 , 50 , true )
8+ ->save ('/path/to/image/mypic_thumb.jpg ' );
Original file line number Diff line number Diff line change 1+ <?php
2+
3+ $ config ['image_library ' ] = 'gd2 ' ;
4+ $ config ['source_image ' ] = '/path/to/image/mypic.jpg ' ;
5+ $ config ['create_thumb ' ] = TRUE ;
6+ $ config ['maintain_ratio ' ] = TRUE ;
7+ $ config ['width ' ] = 75 ;
8+ $ config ['height ' ] = 50 ;
9+
10+ $ this ->load ->library ('image_lib ' , $ config );
11+
12+ $ this ->image_lib ->resize ();
You can’t perform that action at this time.
0 commit comments