diff options
| author | Savetheinternet <savetheinternet@n0v4.com> | 2011-04-12 22:58:01 +1000 |
|---|---|---|
| committer | Savetheinternet <savetheinternet@n0v4.com> | 2011-04-12 22:58:01 +1000 |
| commit | 5f94009fad79ec2babaadb8e16e6f83f163d2964 (patch) | |
| tree | 9e6059a2a2a60d1f9b332aeeb28034f58311f74e | |
| parent | e7eae328926cfb08cc56a11504790649a02dd08e (diff) | |
When a thumbnailed image is going to be the same (in dimension), just copy the entire file and use that as a thumbnail instead. (optional)
| -rw-r--r-- | inc/config.php | 3 | ||||
| -rw-r--r-- | post.php | 20 |
2 files changed, 18 insertions, 5 deletions
diff --git a/inc/config.php b/inc/config.php index 8818e646..6b7a7e8c 100644 --- a/inc/config.php +++ b/inc/config.php @@ -153,6 +153,9 @@ $config['thumb_width'] = 255; $config['thumb_height'] = 255; + // When a thumbnailed image is going to be the same (in dimension), just copy the entire file and use that as a thumbnail instead of resizing/redrawing + $config['minimum_copy_resize'] = true; + // Store image hash in the database for r9k-like boards implementation soon // Function name for hashing // sha1_file, md5_file, etc. @@ -414,13 +414,23 @@ $post['filehash'] = $config['file_hash']($post['file']); $post['filesize'] = filesize($post['file']); - $image = createimage($post['extension'], $post['file']); - // Create a thumbnail - $thumb = resize($image, $post['width'], $post['height'], $post['thumb'], $config['thumb_width'], $config['thumb_height']); - $post['thumbwidth'] = $thumb['width']; - $post['thumbheight'] = $thumb['height']; + if($config['minimum_copy_resize'] && $post['width'] < $config['thumb_width'] && $post['height'] < $config['thumb_height']) { + // Copy, because there's nothing to resize + copy($post['file'], $post['thumb']); + + $post['thumbwidth'] = $post['width']; + $post['thumbheight'] = $post['height']; + } else { + $image = createimage($post['extension'], $post['file']); + + // Create a thumbnail + $thumb = resize($image, $post['width'], $post['height'], $post['thumb'], $config['thumb_width'], $config['thumb_height']); + + $post['thumbwidth'] = $thumb['width']; + $post['thumbheight'] = $thumb['height']; + } } if($post['has_file'] && $config['image_reject_repost'] && $p = getPostByHash($post['filehash'])) { |
