4images Forum & Community

4images Modifications / Modifikationen => Templates & Styles (Requests & Discussions) => Topic started by: nikitaspj on January 30, 2008, 04:50:13 PM

Title: Thumbnail exact size and border style(color rollover etc) ??
Post by: nikitaspj on January 30, 2008, 04:50:13 PM
what i want to do is to be able to have all the thumbs the same size
and ..
to be able to change the thumb border color  , AND OR , to make a rollover effect (from a change border color to that lens-blur effect)

It is real important to have access to these settings if u want to create descent templates,even if u will not use them,
Title: Re: Thumbnail exact size and border style(color rollover etc) ??
Post by: nikitaspj on February 04, 2008, 11:54:14 PM
Hallo ?  anybody  ?
Title: Re: Thumbnail exact size and border style(color rollover etc) ??
Post by: nikitaspj on February 07, 2008, 02:29:05 PM
Hallo Hallo somebody ?
After seven days a reply ?
I complain a little
Title: Re: Thumbnail exact size and border style(color rollover etc) ??
Post by: Nicky on February 07, 2008, 02:50:23 PM
hi,

if you want to have all thumbs same size, you have to have all pics in same size..

example 1024x1024

you will have thumbs in same size...

different pics can not have same thumb size.. except you want to set width and height by your own (pics will be streched)..
Title: Re: Thumbnail exact size and border style(color rollover etc) ??
Post by: mawenzi on February 07, 2008, 02:53:25 PM
1. Settings in ACP -> General -> Settings -> Upload Settings -> Thumbnail Size / Proportions ...
2. try this ... http://www.4homepages.de/forum/index.php?topic=4598.msg52675#msg52675
3. for rollover with blur effect use css coding ... like here ... www.myart.es
... and ...
4. we dont need several postings for the same request ...
Title: Re: Thumbnail exact size and border style(color rollover etc) ??
Post by: nikitaspj on February 07, 2008, 06:24:09 PM
I noticed that u were working on a BugFix release these days.
So excuse me for complaining a bit ,for the delay , i understand that u were surrounded by code .
And that many users they recieve free help.And this is respected.
It is just that i purchased a license only for the customer support
So excuse me if i shaked the tree the wrong time

As for the request.
I want the thumbs to be an exact width and height but not to be streched.Example i might want them square but not to stretch the thumbs.Is there ANY way to do that ?
Title: Re: Thumbnail exact size and border style(color rollover etc) ??
Post by: mawenzi on February 07, 2008, 06:52:58 PM
... I think, I'm not the right person for your "customer support problem" ...
... I'm only a member of this community ...
... developers, distributors, administrators are Jan and Kai ...

for the request
... I think there is a request with some code snippets in the forum "Mods & Plugins (Requests & Discussions)" by "trez" ...
... but I don't know if that works for your special request ...
Title: Re: Thumbnail exact size and border style(color rollover etc) ??
Post by: a_rojilla on February 11, 2008, 04:27:09 AM
For non-distorted square thumbs (first the thumb is created with a minimum height or width -depending on if the image is horizontal or vertical- and then the final thumbnail is extracted from the center  -this, of course, won't affect to already square images), follow these steps:

1.- Open includes/image_utils.php

2.- Find the function create_thumbnail (near the end), it's all this code:

Code: [Select]
function create_thumbnail($src, $dest, $quality, $dimension, $resize_type) {
  global $convert_options;

  if (file_exists($dest)) {
    @unlink($dest);
  }
  $image_info = (defined("IN_CP")) ? getimagesize($src) : @getimagesize($src);
  if (!$image_info) {
    return false;
  }
  $width_height = get_width_height($dimension, $image_info[0], $image_info[1], $resize_type);
  $resize_handle = "resize_image_".$convert_options['convert_tool'];
  if ($resize_handle($src, $dest, $quality, $width_height['width'], $width_height['height'], $image_info)) {
    @chmod($dest, CHMOD_FILES);
    return true;
  }
  else {
    return false;
  }
}

3.- Select all that code and either remove or comment it (the latter is a better option just in case you need the code again).

4.- Paste this code just where the removed code was (or if you just commented it out, paste the code either before of after the commented code -it doesn't matter):

Code: [Select]
function resize_image_gd_thumb($src, $dest, $quality, $width, $height, $image_info) {
  global $convert_options;

$xpos = 0;
$ypos = 0;

      if ($width > $height) {
        $xpos = ceil((($width - $height) / 2) - ($width - $height));
      } elseif ($height > $width) {
        $ypos = ceil((($height - $width) / 2)- ($height - $width));
      } else {
        $xpos = 0;
        $ypos = 0;
      }

  $types = array(1 => "gif", 2 => "jpeg", 3 => "png");
  if ($convert_options['convert_gd2']) {
    $thumb = imagecreatetruecolor(150, 150);
  }
  else {
    $thumb = imagecreate(150, 150);
  }
  $image_create_handle = "imagecreatefrom".$types[$image_info[2]];
  if ($image = $image_create_handle($src)) {
    if ($convert_options['convert_gd2']) {
      imagecopyresampled($thumb, $image, $xpos, $ypos, 0, 0, $width, $height, ImageSX($image), ImageSY($image));
    }
    else {
      imagecopyresized($thumb, $image, $xpos, $ypos, 0, 0, $width, $height, ImageSX($image), ImageSY($image));
    }

    if ($image_info[2] == 3) {
      $quality = 9;
    }

    $image_handle = "image".$types[$image_info[2]];
    $image_handle($thumb, $dest, $quality);
    imagedestroy($image);
    imagedestroy($thumb);
  }
  return (file_exists($dest)) ? 1 : 0;
}

function create_thumbnail($src, $dest, $quality, $dimension, $resize_type) {
  global $convert_options;

  if (file_exists($dest)) {
    @unlink($dest);
  }
  $image_info = (defined("IN_CP")) ? getimagesize($src) : @getimagesize($src);
  if (!$image_info) {
    return false;
  }

if ($image_info[0] > $image_info[1]) {
$width = ceil($image_info[0] / ($image_info[1]/150));
$height = 150;
} elseif ($image_info[1] > $image_info[0]) {
$width = 150;
$height = ceil($image_info[1] / ($image_info[0]/150));
} else {
$width = 150;
$height = 150;
}

  $resize_handle = "resize_image_".$convert_options['convert_tool']."_thumb";
  if ($resize_handle($src, $dest, $quality, $width, $height, $image_info)) {
    @chmod($dest, CHMOD_FILES);
    return true;
  }
  else {
    return false;
  }
}

5.- In this code, look for the number 150 and replace it with the size you want for your thumbs (if you want 80x80 thumbs then replace every 150 with a 80).

That's all. Now, let me tell you this: this should work even if you added some MODs to image_utils.php (like that for an image height bug when resizing, I remember), but just be careful if you modified the file before. And, most importantly, the code I posted will only work if you use GD as your converter (I tested the code with GD2).

Good luck and, please tell me if it worked for you.

Regards.

Forgot to say: if you set 150, or 80, whatever, as the size for your thumbnails, note that samller images will be scaled up (if you set 150 and someone uploads a, say, 100x100 image, it will be resized to fill the 150 pixel space -so remember that the size for your thumbnails will be a fixed size and the best you can do is to not upload images smaller than taht size -anyway, does it make sense to upload images smaller than the thumbnails themselves?).
Title: Re: Thumbnail exact size and border style(color rollover etc) ??
Post by: nikitaspj on February 27, 2008, 04:11:41 PM
a_rojilla T H A N X !

It works ok until now (some tests ) and the good thing is that it does not affect or get affected even when i Resize thumbs from the AutoImage Resizer.
I have to tell you that your reply saved me
again THANX !
Title: Re: Thumbnail exact size and border style(color rollover etc) ??
Post by: a_rojilla on March 01, 2008, 12:19:50 PM
It works ok until now (some tests ) and the good thing is that it does not affect or get affected even when i Resize thumbs from the AutoImage Resizer.

Nice to hear/read it works for you as well. I guess this could be published as a new MOD for those who also want square thumbs (they are easier to work with -for making rows, columns or mosaics-, more pleasant to look at and even a little more effective since hidding some parts of the final image may encourage some clicks).

Regards.
Title: Re: Thumbnail exact size and border style(color rollover etc) ??
Post by: weissinger on April 15, 2009, 07:48:02 PM
Hello.

Nice Codesnippet!
But I use imagemagick.
What should I change that I can
create square thumbs with imagemagick?  :roll:

Thanks.

Title: Re: Thumbnail exact size and border style(color rollover etc) ??
Post by: Sebas Bonito on July 07, 2009, 03:42:13 PM
Thx, this works great, but NOT with the [MOD] Media sites v1.5.6 (http://www.4homepages.de/forum/index.php?topic=24054.0).
For every new video I have to delete the thumbs via ftp, and must use the [Plugin] Rebuild Thumbnails v1.1 (http://www.4homepages.de/forum/index.php?topic=7059.0) to resize it to my square-size manually!
Title: Re: Thumbnail exact size and border style(color rollover etc) ??
Post by: Sebas Bonito on July 16, 2009, 06:14:04 PM
Thx, this works great, but NOT with the [MOD] Media sites v1.5.6 (http://www.4homepages.de/forum/index.php?topic=24054.0).
For every new video I have to delete the thumbs via ftp, and must use the [Plugin] Rebuild Thumbnails v1.1 (http://www.4homepages.de/forum/index.php?topic=7059.0) to resize it to my square-size manually!

PUSH

I really need help in this  :|
Title: Re: Thumbnail exact size and border style(color rollover etc) ??
Post by: Maria2009 on August 05, 2009, 03:54:17 AM
thanks so much for useful info

keyword (http://globolstaff.com/)
Title: Re: Thumbnail exact size and border style(color rollover etc) ??
Post by: Rembrandt on August 05, 2009, 05:20:05 AM
Hi!
Thx, this works great, but NOT with the [MOD] Media sites v1.5.6 (http://www.4homepages.de/forum/index.php?topic=24054.0).
For every new video I have to delete the thumbs via ftp, and must use the [Plugin] Rebuild Thumbnails v1.1 (http://www.4homepages.de/forum/index.php?topic=7059.0) to resize it to my square-size manually!
und was genau funktioniert nicht, b.z.w was möchtest du?

mfg Andi
Title: Re: Thumbnail exact size and border style(color rollover etc) ??
Post by: batu544 on June 03, 2010, 08:26:30 PM
Hi,
    Before using this little change could anyone please let me know what is the use of   resize_image_gd_thumb function ?

Quote
Code: [Select]
function resize_image_gd_thumb($src, $dest, $quality, $width, $height, $image_info) {
  global $convert_options;

$xpos = 0;
$ypos = 0;

      if ($width > $height) {
        $xpos = ceil((($width - $height) / 2) - ($width - $height));
      } elseif ($height > $width) {
        $ypos = ceil((($height - $width) / 2)- ($height - $width));
      } else {
        $xpos = 0;
        $ypos = 0;
      }

  $types = array(1 => "gif", 2 => "jpeg", 3 => "png");
  if ($convert_options['convert_gd2']) {
    $thumb = imagecreatetruecolor(150, 150);
  }
  else {
    $thumb = imagecreate(150, 150);
  }
  $image_create_handle = "imagecreatefrom".$types[$image_info[2]];
  if ($image = $image_create_handle($src)) {
    if ($convert_options['convert_gd2']) {
      imagecopyresampled($thumb, $image, $xpos, $ypos, 0, 0, $width, $height, ImageSX($image), ImageSY($image));
    }
    else {
      imagecopyresized($thumb, $image, $xpos, $ypos, 0, 0, $width, $height, ImageSX($image), ImageSY($image));
    }

    if ($image_info[2] == 3) {
      $quality = 9;
    }

    $image_handle = "image".$types[$image_info[2]];
    $image_handle($thumb, $dest, $quality);
    imagedestroy($image);
    imagedestroy($thumb);
  }
  return (file_exists($dest)) ? 1 : 0;
}

function create_thumbnail($src, $dest, $quality, $dimension, $resize_type) {
  global $convert_options;

  if (file_exists($dest)) {
    @unlink($dest);
  }
  $image_info = (defined("IN_CP")) ? getimagesize($src) : @getimagesize($src);
  if (!$image_info) {
    return false;
  }

if ($image_info[0] > $image_info[1]) {
$width = ceil($image_info[0] / ($image_info[1]/150));
$height = 150;
} elseif ($image_info[1] > $image_info[0]) {
$width = 150;
$height = ceil($image_info[1] / ($image_info[0]/150));
} else {
$width = 150;
$height = 150;
}

  $resize_handle = "resize_image_".$convert_options['convert_tool']."_thumb";
  if ($resize_handle($src, $dest, $quality, $width, $height, $image_info)) {
    @chmod($dest, CHMOD_FILES);
    return true;
  }
  else {
    return false;
  }
}
I don't see any use of this function and I feel its unnecessary..


Please correct me, if I am wrong..


Thanks,
batu544

Edit: ..  My mistake.. Its working fine.  :mrgreen:  ( my php knowledge is a BIG zero.. )


Title: Re: Thumbnail exact size and border style(color rollover etc) ??
Post by: mayashu on July 06, 2010, 12:21:19 PM
I inserted the code in the right place but when I am in admin panel the Auto-Thumbnailer wont load I have a blank page....
I dezactivate the code and is loading. Anyone know how to fix it?
Thanks
Dragos Popovici
Title: Re: Thumbnail exact size and border style(color rollover etc) ??
Post by: V@no on July 06, 2010, 05:06:10 PM
I inserted the code in the right place but when I am in admin panel the Auto-Thumbnailer wont load I have a blank page....
I dezactivate the code and is loading. Anyone know how to fix it?
Thanks
Dragos Popovici


Restore backups and try again? You must replace the existing entire create_thumbnail function with the new code, not just insert new code.

Thx, this works great, but NOT with the [MOD] Media sites v1.5.6 (http://www.4homepages.de/forum/index.php?topic=24054.0).
For every new video I have to delete the thumbs via ftp, and must use the [Plugin] Rebuild Thumbnails v1.1 (http://www.4homepages.de/forum/index.php?topic=7059.0) to resize it to my square-size manually!
It will be fixed in Media Sites v1.11
Title: Re: Thumbnail exact size and border style(color rollover etc) ??
Post by: mayashu on August 24, 2010, 08:31:08 AM
Thanks it orked fine after removing old code ( I was just coment it)
Thanks
Title: Re: Thumbnail exact size and border style(color rollover etc) ??
Post by: henary on December 12, 2010, 01:58:33 AM
Hello,

i'd like to use this fine MOD to have all thumb in same dimension 150x100 (ie 3:2 format). The original files will be in 3:2 or 4:3 or something else  :wink: so i'm think i've to calculate something in code.
Did anybody finish this?

I use ImageMagick by defaut in 4img i and change one line
Code: [Select]
$resize_handle = "resize_image_gd_thumb"; to use gd2 for this. May i use better ImageMagick for doing this?

Thanks for any hint,
Henry
Title: Re: Thumbnail exact size and border style(color rollover etc) ??
Post by: masterred on March 19, 2012, 05:54:17 PM
hello

need some help to use the measures as vertical thumbnails, modify the file mentioned in the include and resize the images smaller the perfect, only to climb a vertical image of me taking the measures the horizontal and out deconfigured, how could I do to take steps reverse

width 140 height 280 perfect size
necesito las medidas exactas 280x140

thanks
Title: Re: Thumbnail exact size and border style(color rollover etc) ??
Post by: zimba on May 22, 2012, 08:47:22 AM
Thumbnails  - da wäre ein upgrade ganz sexy das man einfach die Thumbnails so erstellen kann, dass man diese auch als Sahrepics für zB. Facebook nutzen kann - sprich ein optimal Quadratischer Ausschnitt aus dem jeweiligen Bild - im Moment wird ein Bild das zu hoch oder zu wenig hoch ist nicht als Sharepic erkannt. Das es proportional verkleiner wird, ist echt ganz schlecht für die Viralität einer Seite - was gerade bei BILDERN eine grosse Rolle spielt.

Eventuell könnt ihr das in das neue Update einfliessen lassen das man Zeitgemässe "thumbnails" erstellen kann.