It's integrated into plupload, which is used for uploading any and all attachments in 3.1.Volksdevil wrote:So the building blocks are there but yet nobody has taken it on as a standalone extension for posts.
It's integrated into plupload, which is used for uploading any and all attachments in 3.1.Volksdevil wrote:So the building blocks are there but yet nobody has taken it on as a standalone extension for posts.
Code: Select all
if (!$this->upload->valid_dimensions($this))
{
$this->error[] = $user->lang($this->upload->error_prefix . 'WRONG_SIZE',
$user->lang('PIXELS', (int) $this->upload->min_width),
$user->lang('PIXELS', (int) $this->upload->min_height),
$user->lang('PIXELS', (int) $this->upload->max_width),
$user->lang('PIXELS', (int) $this->upload->max_height),
$user->lang('PIXELS', (int) $this->width),
$user->lang('PIXELS', (int) $this->height));
return false;
}
return true;
}
Code: Select all
if (!$this->upload->valid_dimensions($this))
{
$valid = $this->create_thumb();
if (!$valid)
{
$this->error[] = sprintf($user->lang[$this->upload->error_prefix . 'WRONG_SIZE'], $this->upload->min_width, $this->upload->min_height, $this->upload->max_width, $this->upload->max_height, $this->width, $this->height);
return false;
}
}
return true;
}
function create_thumb()
{
global $config;
if ($this->width > $this->height)
{
$thumb_width = $this->upload->max_width;
$thumb_height = $this->height*($this->upload->max_height/$this->width);
}
else if ($this->width < $this->height)
{
$thumb_width = $this->width*($this->upload->max_width/$this->height);
$thumb_height = $this->upload->max_height;
}
else /* $this->width == $this->height */
{
$thumb_width = $this->upload->max_width;
$thumb_height = $this->upload->max_height;
}
if ($config['img_imagick'] && function_exists('passthru'))
{
$quality = '';
$sharpen = '';
$frame = '';
$animation = '';
if ( $this->mimetype == 'image/jpeg' )
{
$quality = '-quality 80'; // 80%
/** Reduction in linear dimensions below which sharpening will be enabled */
if ( ( $thumb_width + $thumb_height ) / ( $this->width + $this->height ) < 0.85 )
{
$sharpen = '-sharpen 0x0.4';
}
}
elseif ($this->mimetype == 'image/png')
{
$quality = '-quality 95'; // zlib 9, adaptive filtering
}
elseif ($this->mimetype == 'image/gif')
{
if($this->width * $this->height > 1.0e6)
{
// Extract initial frame only
$frame = '[0]';
}
else
{
$animation = ' -coalesce ';
}
}
if (substr($config['img_imagick'], -1) !== '/')
{
$config['img_imagick'] .= '/';
}
$cmd =
escapeshellcmd($config['img_imagick']) . 'convert' . ((defined('PHP_OS') && preg_match('#^win#i', PHP_OS)) ? '.exe' : '') .
" {$quality} -background white -size {$this->width} ".
escapeshellarg($this->destination_file . $frame) .
$animation .
// For the -resize option a "!" is needed to force exact size,
// or ImageMagick may decide your ratio is wrong and slice off
// a pixel.
' -thumbnail ' . escapeshellarg( "{$thumb_width}x{$thumb_height}!" ) .
" -depth 8 $sharpen " .
escapeshellarg($this->destination_file) . ' 2>&1';
@passthru($cmd);
if (($this->image_info = @getimagesize($this->destination_file)) !== false)
{
$this->width = $this->image_info[0]; // the _real_ width
$this->height = $this->image_info[1]; // the _real_ height
if ($this->upload->valid_dimensions($this))
{
return true;
}
}
}
if (extension_loaded('gd'))
{
/* This code is greatly based on MediaWiki's thumbnail generation process */
$typemap = array(
'image/gif' => array( 'imagecreatefromgif', 'palette', 'imagegif' ),
'image/jpeg' => array( 'imagecreatefromjpeg', 'truecolor', array( __CLASS__, 'imagejpegwrapper' ) ),
'image/png' => array( 'imagecreatefrompng', 'bits', 'imagepng' ),
'image/vnd.wap.wbmp' => array( 'imagecreatefromwbmp', 'palette', 'imagewbmp' ),
'image/xbm' => array( 'imagecreatefromxbm', 'palette', 'imagexbm' ),
);
if (!isset( $typemap[$this->mimetype] ))
{
return false;
}
list($loader, $color_style, $save_type) = $typemap[$this->mimetype];
if (!function_exists($loader))
{
return false;
}
$src_image = call_user_func( $loader, $this->destination_file );
$thumb = imagecreatetruecolor($thumb_width, $thumb_height);
// Initialise the destination image to transparent instead of
// the default solid black, to support PNG and GIF transparency nicely
$background = imagecolorallocate( $thumb, 0, 0, 0 );
imagecolortransparent( $thumb, $background );
imagealphablending( $thumb, false );
if( $color_style == 'palette' ) {
imagecopyresized( $thumb, $src_image,
0,0,0,0,
$thumb_width, $thumb_height, $this->width, $this->height );
} else {
imagecopyresampled( $thumb, $src_image,
0,0,0,0,
$thumb_width, $thumb_height, $this->width, $this->height );
}
imagesavealpha( $thumb, true );
call_user_func( $save_type, $thumb, $this->destination_file );
imagedestroy($thumb);
imagedestroy($src_image);
$this->width = $thumb_width;
$this->height = $thumb_height;
return true;
}
return false;
}
static function imagejpegwrapper( $dst_image, $thumb_path ) {
imageinterlace( $dst_image );
imagejpeg( $dst_image, $thumb_path, 95 );
}
I agree I do not want super big pictures on my site, face it in the real world teaching every user to resize a picture before uploading is NOT going to happen so let it go, and if you set limits your just blocking the creativity of the users most the time you aggravate them. Therefore I set my site where it will accept about any size image you can take and it resizes it to 800x600.][Moon][Shine][ wrote:This is not about just resizing displayed images as discussed in the ReIMG Image Resizer thread, but an extension that hooks itself to the attachment function and post-processes files if they are images.
The idea is to optimize forum performance by taking care of image type and file size. People tend to upload pics directly from their camera, resulting in megapixel images with several MB in size. Even if the displayed image is downsized to fit the max width of the posting area it is still stored and loaded in full size, eating away storage space on the server, as well as bandwidth and results in longer page load times (important for search engine rating).
So if a forum member uploads a picture as attachment, the file should automatically be resized to a configured value (like 800x600 or 600x800 keeping the aspect ratio) and converted to JPG with a configured JPG quality setting (like 80%) if it's a PNG or GIF (with the exception of animated GIFs; if such distinction is not possible than no GIF conversion, so that animated GIFs are still possible). AFAIK such functionality should easily be possible using ImageMagick, which is available on any webserver.
Such picture treatment has a huge impact. Right now I do that processing on my Vanilla forum manually (which is cumbersome if people upload a lot of pictures), and I can tell that it brings down pictures file sizes from up to 5 MB for regular pics directly coming from a camera to less than 100 KB most of the times.
It would be really great to have such automatic picture attachment treating available.
That is a genius idea if I had this option on my site back in 2003 I would not have hundreds of post with missing images on my site, the valuable information they deposited on my site would have been preserved you need to make this option into a Extension please!Holger wrote:On my sites:
When users post external images/photos by using the IMG-tag we notice this because they are not watermarked with our choosen logo (the watermark is attached when using the forums attachment- or our custom upload-function).
When we (mods/admins) notice the external images we can click on a button (located at the quote-button area) at each post.
When clicking this button the external image/photo is transfered to our servers and saved in a separate folder.
The post is automatically updated and the external IMG-link is replaced with the local one.
Additionally the original link is added as text below the image/photo.
In the settings for posting the user can tick an option that prevents us from copying the image/photo, the one-click-transfer button is then hidden.
Example 1:
In this screenshot you can see the watermark.
No need to do anything because the image was uploaded with one of the forums upload-functions and is saved on our own servers.
Example 2:
In this screenshot you can see NO watermark, it has to be external.
The mods/admins now click on one-click copy button to transfer the image to our own servers.
When clicking the one-click copy button the post also is updated and the external URL is changed to the local, additionally the original URL is added below the image/photo.
- It is important that the users can block the copying of images/photos in the message options!
- The one-click-copy does not work if the IMG-URL is https
- The one-click-copy does not watermark the image/photo
I agree too. I would definitely love that! I never allowed my users to use attached files because of that but I receive more and more requests about that kind of function. People keep saying that they're tired of using hosting sites like Photobucket when it is so simple to upload images on Facebook for example...Swanny wrote:+1, I agree 100%.][Moon][Shine][ wrote:I have no idea why any admin would NOT want this functionality, as it has only advantages. Why would an admin not want to save bandwidth, server storage space and optimize page load time? Maybe most admins simply don't know about the impact of that feature, but if explained and shown the benefits I guess everybody will want to have it!
That's a MOD so pretty useless for the purposes of this topic.ViolaF wrote:Real Remote [img] Resize
Users browsing this forum: No registered users and 9 guests