Skip to content

Commit bb1ba43

Browse files
authored
v0.0.4
1 parent 30cbb3e commit bb1ba43

File tree

11 files changed

+63
-58
lines changed

11 files changed

+63
-58
lines changed

README.md

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ It can change the image size and/or the image file size. Rotate thumbnails accor
1616
- Remove EXIF data
1717

1818
## Requirements
19-
- php 7.3 or higher
19+
- php 7.0 or higher
2020
- phpBB 3.2.4 or higher
2121
- php the Imagick class
2222

@@ -27,10 +27,12 @@ For full functionality "Maximum file size" in "ACP" > "Posting" > "Attachment se
2727
For full functionality "Maximum image dimensions" in "ACP" > "Posting" > "Attachment settings" must be set to 0. This is done automatically during the migration.
2828

2929
## Update
30-
For update to v0.0.3 please `disable` the extension and `delete data` before copy the new files to `phpBB3/ext/imcger/imgupload`.
30+
For update from v0.0.1 or v0.0.2 please `disable` the extension and `delete data` before copy the new files to `phpBB3/ext/imcger/imgupload`.
3131

3232
## Changelog
3333

34+
### v0.0.4 (18-03-2022) Cleanup Code
35+
3436
### v0.0.3 (20-02-2022) Code changes
3537

3638
### v0.0.2 (19-02-2022) Code changes

imcger/imgupload/README.md

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ It can change the image size and/or the image file size. Rotate thumbnails accor
1616
- Remove EXIF data
1717

1818
## Requirements
19-
- php 7.3 or higher
19+
- php 7.0 or higher
2020
- phpBB 3.2.4 or higher
2121
- php the Imagick class
2222

@@ -27,10 +27,12 @@ For full functionality "Maximum file size" in "ACP" > "Posting" > "Attachment se
2727
For full functionality "Maximum image dimensions" in "ACP" > "Posting" > "Attachment settings" must be set to 0. This is done automatically during the migration.
2828

2929
## Update
30-
For update to v0.0.3 please `disable` the extension and `delete data` before copy the new files to `phpBB3/ext/imcger/imgupload`.
30+
For update from v0.0.1 or v0.0.2 please `disable` the extension and `delete data` before copy the new files to `phpBB3/ext/imcger/imgupload`.
3131

3232
## Changelog
3333

34+
### v0.0.4 (18-03-2022) Cleanup Code
35+
3436
### v0.0.3 (20-02-2022) Code changes
3537

3638
### v0.0.2 (19-02-2022) Code changes

imcger/imgupload/acp/main_module.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ public function main($id, $mode)
4949

5050
trigger_error($user->lang('ACP_IMCGER_SETTINGS_SAVED') . adm_back_link($this->u_action));
5151
}
52-
52+
5353
$filesize = get_formatted_filesize($config['imcger_imgupload_max_filesize'], false, array('mb', 'kb', 'b'));
5454

5555
$template->assign_vars(array(

imcger/imgupload/composer.json

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,8 @@
33
"type" : "phpbb-extension",
44
"description" : "Using ImageMagick php librarie for image attachments and creating thumbnails.",
55
"homepage" : "https://github.com/IMC-GER/phpBB-Image-upload-use-ImageMagick",
6-
"version" : "0.0.3",
7-
"time" : "2022-02-20",
6+
"version" : "0.0.4",
7+
"time" : "2022-03-18",
88
"license" : "GPL-2.0-only",
99
"authors" : [{
1010
"name" : "imc-ger",
@@ -14,7 +14,7 @@
1414
}
1515
],
1616
"require" : {
17-
"php" : ">=7.4.0",
17+
"php" : ">=7.0.0",
1818
"composer/installers" : "~1.0"
1919
},
2020
"extra" : {

imcger/imgupload/event/main_listener.php

Lines changed: 31 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -41,14 +41,14 @@ public function __construct
4141
$this->config = $config;
4242
}
4343

44-
static public function getSubscribedEvents()
44+
public static function getSubscribedEvents()
4545
{
4646
return array(
47-
'core.thumbnail_create_before' => 'imcger_create_tumbnail',
48-
'core.modify_uploaded_file' => 'imcger_modify_uploaded_file',
47+
'core.thumbnail_create_before' => 'imcger_create_tumbnail',
48+
'core.modify_uploaded_file' => 'imcger_modify_uploaded_file',
4949
);
5050
}
51-
51+
5252
/**
5353
* Create a thumbnail using IMagick
5454
*
@@ -66,7 +66,7 @@ public function imcger_create_tumbnail($event)
6666
$thumb = $this->image_auto_rotate($thumbnail);
6767

6868
/* changed the image heigth and width when it rotate */
69-
if($thumb['rotate'])
69+
if ($thumb['rotate'])
7070
{
7171
$new_width = $event['new_height'];
7272
$new_height = $event['new_width'];
@@ -75,25 +75,25 @@ public function imcger_create_tumbnail($event)
7575
{
7676
$new_width = $event['new_width'];
7777
$new_height = $event['new_height'];
78-
}
78+
}
7979

8080
/* resize the Image */
8181
$thumbnail->resizeImage($new_width, $new_height, \Imagick::FILTER_LANCZOS, 1, false);
82-
82+
8383
/* Set image format */
8484
$this->set_image_format($thumbnail, $event['mimetype']);
8585

8686
/* Compression quality is read from config, set in ACP */
8787
$this->set_image_compression($thumbnail, $this->config['imcger_imgupload_tum_quality']);
8888

8989
/* Strip EXIF data and image profile */
90-
if($this->config['imcger_imgupload_del_exif'])
90+
if ($this->config['imcger_imgupload_del_exif'])
9191
{
9292
$thumbnail->stripImage();
9393
}
9494

9595
/* Store the image */
96-
if($thumbnail->writeImage($event['destination']))
96+
if ($thumbnail->writeImage($event['destination']))
9797
{
9898
$thumbnail_created = true;
9999
}
@@ -141,68 +141,68 @@ public function imcger_modify_uploaded_file($event)
141141
$side_ratio = $width / $height;
142142

143143
/* set new images width */
144-
if($image_max_width && $image_max_width < $width)
144+
if ($image_max_width && $image_max_width < $width)
145145
{
146146
$width = $image_max_width;
147147
$height = (int) ($width / $side_ratio);
148-
148+
149149
$write_image = true;
150150
}
151151

152152
/* set new images height */
153-
if($image_max_height && $image_max_height < $height)
153+
if ($image_max_height && $image_max_height < $height)
154154
{
155155
$height = $image_max_height;
156156
$width = (int) ($height * $side_ratio);
157-
157+
158158
$write_image = true;
159159
}
160160

161161
/* when changed dimensions resize the Image */
162-
if($write_image)
162+
if ($write_image)
163163
{
164164
$image->resizeImage($width, $height, \Imagick::FILTER_LANCZOS, 1, false);
165165
}
166166

167167
/* when not resize don`t changed image quality when it less then quality set in ACP */
168-
if($write_image || $image_quality < $image->getImageCompressionQuality())
168+
if ($write_image || $image_quality < $image->getImageCompressionQuality())
169169
{
170170
/* set compression quality is read from config */
171171
$this->set_image_compression($image, $image_quality);
172-
172+
173173
$write_image = true;
174174
}
175175

176176
/* Set image format */
177177
$this->set_image_format($image, $event['filedata']['mimetype']);
178178

179179
/* strip EXIF data and image profile */
180-
if($image_del_exif)
180+
if ($image_del_exif)
181181
{
182182
$image->stripImage();
183-
183+
184184
$write_image = true;
185185
}
186186

187187
/* shrink file size wenn greater then set in ACP */
188-
if($image_max_filesize && $event['filedata']['filesize'] > $image_max_filesize)
188+
if ($image_max_filesize && $event['filedata']['filesize'] > $image_max_filesize)
189189
{
190190
/* set compression quality is read from config */
191191
$this->set_image_compression($image, $image_quality);
192192

193193
/* set the max file size for the image */
194194
$filesize = $this->image_auto_length($image, $image_max_filesize);
195-
195+
196196
$write_image = true;
197197
}
198-
199-
/* set return value new file size */
198+
199+
/* set return value new file size */
200200
$filedata_array = $event['filedata'];
201201
$filedata_array['filesize'] = $filesize ?? strlen($image->getImageBlob());
202202
$event['filedata'] = $filedata_array;
203203

204204
/* store the image when changed attribute */
205-
if($write_image || $img['rotate'])
205+
if ($write_image || $img['rotate'])
206206
{
207207
$image->writeImage($file_path);
208208
$image->clear();
@@ -241,7 +241,7 @@ function set_image_format($image, $mimetype)
241241
}
242242

243243
$image->setImageFormat($imageformat);
244-
244+
245245
return($imageformat);
246246
}
247247

@@ -257,7 +257,7 @@ function set_image_compression($image, $quality)
257257
}
258258

259259
/**
260-
* rotate and resize the generated image
260+
* rotate the generated image
261261
*
262262
* @param object $image image object
263263
* @param integer $width new witdth of the image
@@ -270,7 +270,7 @@ function image_auto_rotate($image)
270270
{
271271
$is_rotate = false;
272272
$is_changed = true;
273-
273+
274274
/* read the orientation from the image */
275275
if (!($image_orientation = $image->getImageOrientation()))
276276
{
@@ -328,7 +328,7 @@ function image_auto_rotate($image)
328328

329329
return(['changed' => $is_changed, 'rotate' => $is_rotate]);
330330
}
331-
331+
332332
/**
333333
* resize the image file
334334
*
@@ -342,18 +342,18 @@ function image_auto_length($image, $new_image_size)
342342
/* get image dimensions */
343343
$width = $image->getImageWidth();
344344
$height = $image->getImageHeight();
345-
345+
346346
$filesize = strlen($image->getImageBlob());
347347

348348
/* image side ratio */
349349
$side_ratio = $width / $height;
350350

351-
while($filesize > $new_image_size)
351+
while ($filesize > $new_image_size)
352352
{
353353
/* calculate the image side in relation to the image area */
354354
$size_ratio = $filesize / $new_image_size;
355355
$xh = sqrt($width * $height / $size_ratio / $side_ratio);
356-
356+
357357
/* calculate the different to new height */
358358
$dh = ($height - $xh) * 0.9;
359359
$dh = $dh > 10 ? $dh : 10;
@@ -364,7 +364,7 @@ function image_auto_length($image, $new_image_size)
364364

365365
/* resize the Image */
366366
$image->resizeImage($width, $height, \Imagick::FILTER_LANCZOS, 1, false);
367-
367+
368368
/* get the file size */
369369
$filesize = strlen($image->getImageBlob());
370370
}

imcger/imgupload/ext.php

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,5 +36,4 @@ public function is_enableable()
3636

3737
return true;
3838
}
39-
4039
}

imcger/imgupload/language/de/imgupload_acp.php

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,10 @@
11
<?php
22
/**
33
*
4-
* This file is part of the ImageMagick Thumbnailer extension for phpBB.
5-
* @package ImageMagick Thumbnailer
6-
* @copyright (c) 2018 Frank Jakobs (canonknipser)
4+
* Image upload use ImageMagick
5+
* An extension for the phpBB Forum Software package.
6+
*
7+
* @copyright (c) 2022, Thorsten Ahlers
78
* @license GNU General Public License, version 2 (GPL-2.0)
89
*
910
*/

imcger/imgupload/language/de_x_sie/imgupload_acp.php

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,10 @@
11
<?php
22
/**
33
*
4-
* This file is part of the ImageMagick Thumbnailer extension for phpBB.
5-
* @package ImageMagick Thumbnailer
6-
* @copyright (c) 2018 Frank Jakobs (canonknipser)
4+
* Image upload use ImageMagick
5+
* An extension for the phpBB Forum Software package.
6+
*
7+
* @copyright (c) 2022, Thorsten Ahlers
78
* @license GNU General Public License, version 2 (GPL-2.0)
89
*
910
*/

imcger/imgupload/language/en/imgupload_acp.php

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,10 @@
11
<?php
22
/**
33
*
4-
* This file is part of the ImageMagick Thumbnailer extension for phpBB.
5-
* @package ImageMagick Thumbnailer
6-
* @copyright (c) 2018 Frank Jakobs (canonknipser)
4+
* Image upload use ImageMagick
5+
* An extension for the phpBB Forum Software package.
6+
*
7+
* @copyright (c) 2022, Thorsten Ahlers
78
* @license GNU General Public License, version 2 (GPL-2.0)
89
*
910
*/

imcger/imgupload/migrations/install_acp_module.php

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -18,18 +18,18 @@ public function effectively_installed()
1818
return isset($this->config['imcger_imgupload_tum_quality']);
1919
}
2020

21-
static public function depends_on()
21+
public static function depends_on()
2222
{
2323
return array('\phpbb\db\migration\data\v32x\v324');
2424
}
2525

2626
public function update_data()
27-
{
27+
{
2828
global $config;
29-
30-
$img_quality = $config['img_quality'];
31-
$max_filesize = $config['max_filesize'];
32-
$img_max_width = $config['img_max_width'];
29+
30+
$img_quality = $config['img_quality'];
31+
$max_filesize = $config['max_filesize'];
32+
$img_max_width = $config['img_max_width'];
3333
$img_max_height = $config['img_max_height'];
3434

3535
return array(

0 commit comments

Comments
 (0)