square thumbs?
jasonh
Joined: 2009-07-09
Posts: 31 |
![]() |
Is there any way I can get g3 to make all my thumbs square? And not square by squishing, but square by cropping, if that makes sense. Working on a theme and I think it would be much better if all thumbs were the same size/orientation. |
|
nivekiam
![]()
Joined: 2002-12-10
Posts: 16504 |
![]() |
No, you'll need to create the plugin for that. It's not meant to be part of the core product. There is already a task made for that and I believe it's marked "Field of Dreams" meaning the core dev team has no intention of coding it themselves or it's extremely low priority if one of them happens to have an interest in that plugin. Someone else will probably need to get to it first. |
|
jasonh
Joined: 2009-07-09
Posts: 31 |
![]() |
Bummer. Thanks for the info. |
|
nivekiam
![]()
Joined: 2002-12-10
Posts: 16504 |
![]() |
http://sourceforge.net/apps/trac/gallery/ticket/445 |
|
Serge D
![]()
Joined: 2009-06-11
Posts: 2466 |
![]() |
Would it be then possible to point at the part of the code where album thumbs are built versus image thumbs? |
|
bharat
![]()
Joined: 2002-05-21
Posts: 7994 |
![]() |
modules/gallery/helpers/gallery_installer.php defines these rules: graphics::add_rule( "gallery", "thumb", "resize", array("width" => 200, "height" => 200, "master" => Image::AUTO), 100); graphics::add_rule( "gallery", "resize", "resize", array("width" => 640, "height" => 480, "master" => Image::AUTO), 100); Note that includes the default values. When you change your settings, we remove and re-add the rules. There's no separate rule for album vs. photo thumbnail. We call graphics::generate() in modules/gallery/helpers/graphics.php to run the rules for any given item. --- |
|
Serge D
![]()
Joined: 2009-06-11
Posts: 2466 |
![]() |
I did get that far, but what puzzles me is that while photo thumbs are square one for albums are proportional. |
|
nivekiam
![]()
Joined: 2002-12-10
Posts: 16504 |
![]() |
Serge D
![]()
Joined: 2009-06-11
Posts: 2466 |
![]() |
Could you visit my gallery? http://photo.dragonsoft.us |
|
nivekiam
![]()
Joined: 2002-12-10
Posts: 16504 |
![]() |
jasonh
Joined: 2009-07-09
Posts: 31 |
![]() |
Serge your thumbs being the same size and proportions no matter the input image is what gave me the idea to ask I see that they are no different now...did you change anything, or did you have some kind of funky leftover from a g2 import maybe? |
|
Serge D
![]()
Joined: 2009-06-11
Posts: 2466 |
![]() |
Yes, they are now all not in the way I want them to be... Story is as following: a) I have square thumbs in my gallery 2. My guess from the looking at the code, import process imports data as is meaning if there is a thumb in G2 which is square, import would pick it as is. This does not apply to albums since thumbs are dynamic b) Last night I did dump everything from thumbs and resizes folders which caused all the pictures goes bad/missing. Following up on the problem I have seen the suggestion to adjust thumb and resize dimensions on the theme options page (200->201->200, 640->639->640) and then rebuild the pictures. (Update 6:28pm) - improved handling of the folder recreation Added a new function /** * Checks if folder for specified file exists otherwise creates necessary folder structure * @param string $path */ static function ensure_path($path) { try { $folder = dirname($path); if (!file_exists($folder)) { Kohana::log("error", "Missing folder detected {" . $folder . "}. Recreated." ); mkdir($folder, 0777, true); } } catch (Exception $e) { // Something went wrong. Kohana::log("error", "Caught exception ensuring the path: {" . $path . " -> " . $folder . "}\n" . $e->getMessage() . "\n" . $e->getTraceAsString()); } } Adjusted following parts of the code static function generate... ... if ($item->thumb_dirty) { $ops["thumb"] = $item->thumb_path(); self::ensure_path($item->thumb_path());} if ($item->resize_dirty && !$item->is_album() && !$item->is_movie()) { $ops["resize"] = $item->resize_path(); self::ensure_path($item->resize_path()); } static function resize... ... } else { // ensure that folder exists self::ensure_path($output_file)); Image::factory($input_file) That may not be final solution, or could be overkill, but it does what it is suppose to do - allows recreate proper folder structure and refresh all resizes/thumbs. This is today. Last night I have created a case http://sourceforge.net/apps/trac/gallery/ticket/550 |
|
jasonh
Joined: 2009-07-09
Posts: 31 |
![]() |
I've kind of gotten the square thumb "look" working so far...it's really just a pretty bad hack... All I did was set my thumb size to 301px (crashed on 300 for some reason and wouldn't start back up), so my 4x6 aspect ratio photos would have 200px on the short side. Then my div blocks in the theme I'm working on are set to 200x200 and the overflow is hidden. changing the vertical alignment on the images will change which portion is shown. The only time this causes a problem is when I have a photo that is cropped to a different aspect ratio. my beta-gallery testing different techniques for a theme (so yeah, it's ugly): http://g3.jasonhight.net It's actually a really simple fix in the command-line for ImageMagick to get what we're looking for, but I can't for the life of me find anywhere in the code that calls the actual IM binary. |
|
Serge D
![]()
Joined: 2009-06-11
Posts: 2466 |
![]() |
To say everything is here in code - classes support crop properly, but I am having difficulty as well to find where crop could be called instead of resize for thumbs... |
|
jasonh
Joined: 2009-07-09
Posts: 31 |
![]() |
For anybody interested, I've come up with a solution for those using ImageMagick: |
|
Serge D
![]()
Joined: 2009-06-11
Posts: 2466 |
![]() |
Ok, will continue there |
|