Anyway to remove the /var/resizes folder?

DixitS

Joined: 2009-10-08
Posts: 31
Posted: Fri, 2011-10-07 01:49

Ive been searching around and a few others have talked about this directory getting fairly large.

For example I have about 1300 pictures in this test gallery3 im testing out (From G2). The main /var/albums is about 144Meg. Then the /var/resizes is about 114Meg. Then the /var/thumbs is about 50meg.

Now in my test gallery3 all the images are no larger than 800pixels on either size (length or width). I have the Advanced Setting set to 800pix.

I tried to rebuild all the pictures (using GreyDragon theme to mark all the thumbnails and pictures for resize), and that didnt change anything. If anything when you click the picture from the album page to show the picture at a larger size, its shows nothing but a tiny box. If you click inside that box, it opens the full size image just fine.

Then I thought let me delete everything inside my /var/resizes and /var/thumbs then try it again. That made it worse. Now I have no thumbs or pictures when clicked (only when i click the tiny box to make it full size). I checked the log and got nothing but errors saying the following example:

Task Rebuild Images started (task id 7)
Unable to rebuild images for 'CIMG0621.JPG'
exception 'Kohana_Exception' with message 'The specified directory, /, is not writable.' in /home/dixitand/public_html/MandS/gallery3/system/libraries/Image.php:388
Stack trace:
#0 /home/dixitand/public_html/MandS/gallery3/modules/gallery/helpers/gallery_graphics.php(71): Image_Core->save('/home/dixitand/...')
#1 [internal function]: gallery_graphics_Core::resize('/home/dixitand/...', '/home/dixitand/...', Array, Object(Item_Model))
#2 /home/dixitand/public_html/MandS/gallery3/modules/gallery/helpers/graphics.php(173): call_user_func_array('gallery_graphic...', Array)
#3 /home/dixitand/public_html/MandS/gallery3/modules/gallery/helpers/gallery_task.php(107): graphics_Core::generate(Object(Item_Model))
#4 [internal function]: gallery_task_Core::rebuild_dirty_images(Object(Task_Model))
#5 /home/dixitand/public_html/MandS/gallery3/modules/gallery/helpers/task.php(90): call_user_func_array('gallery_task::r...', Array)
#6 /home/dixitand/public_html/MandS/gallery3/modules/gallery/controllers/admin_maintenance.php(194): task_Core::run('7')
#7 [internal function]: Admin_Maintenance_Controller->run('7')
#8 /home/dixitand/public_html/MandS/gallery3/modules/gallery/controllers/admin.php(62): call_user_func_array(Array, Array)
#9 [internal function]: Admin_Controller->__call('maintenance', Array)
#10 /home/dixitand/public_html/MandS/gallery3/system/core/Kohana.php(331): ReflectionMethod->invokeArgs(Object(Admin_Controller), Array)
#11 [internal function]: Kohana_Core::instance(NULL)
#12 /home/dixitand/public_html/MandS/gallery3/system/core/Event.php(208): call_user_func_array(Array, Array)
#13 /home/dixitand/public_html/MandS/gallery3/application/Bootstrap.php(67): Event_Core::run('system.execute')
#14 /home/dixitand/public_html/MandS/gallery3/index.php(102): require('/home/dixitand/...')
#15 {main}

So its complaining about not being able to write in the '/' directory. Not sure why its trying to write there. I only delete the folders inside the /var/resizes and /var/thumbs, didnt delete the /var/resizes directory itself or the /var/thumbs directory, just all the contents.

Any way to just tell it to utilize say just the full size image in /var/albums (since I already resized them to 800pix) and just the /var/thumbs for thumbs?

Any hopefully I can get some info on how to fix the cant write to / directory issue.

Dixit

 
DixitS

Joined: 2009-10-08
Posts: 31
Posted: Fri, 2011-10-07 02:57

Ok, managed to get all my thumbnails back. Deleting all the directories under the /var/thumbs was not a good idea as it seems when it tries to rebuild the thumbs, if the directories are not there, it just fails. So had to create all the directories, since there was so many, I just copied the entire /var/albums director to /var/thumbs and let it resize all the thumbs.

Now var/resizes is still an issue. So I manually set all the resize_dirty to all 1 and then rebuild all pictures, so no errors in the log, said all were rebuilt sucessfully.

But when I go to the the picture itself, its still a broken picture. And it still seems to reference the /var/resizes directory. Attached is what it looks like in Google Chrome. In IE9 its even a more tiny box. You can still click it and get the full size.

Is there any way for it to stop referencing the resize folder when there is no need since they are all 800pix or lower? The main setting is already set to 800pix under Advanced.

Dixit

 
CJ00TA

Joined: 2010-03-31
Posts: 34
Posted: Fri, 2011-10-07 18:54

I often have issues where gallery goes nuts... the way that I can tell is to look at the url bar.

I know when I see this similar issue to what you have, I'll have strange paths like http://site/master album 1/sub folder/master album 2/sub folder -> sub folder/image.jpg Obviously I want a url path like http://site/master album/sub album/image.jpg.

Run the gallery cleanup tool and see what you get.

Also, check the security permissions on the deleted folders.

 
floridave
floridave's picture

Joined: 2003-12-22
Posts: 27300
Posted: Fri, 2011-10-07 23:42

Without digging into the core code you will have to live with the resize folder. It is designed that way.

Dave
_____________________________________________
Blog & G2 || floridave - Gallery Team

 
DixitS

Joined: 2009-10-08
Posts: 31
Posted: Fri, 2011-10-07 23:59

Alright, so basically G3 will always create 3 copies of your image you upload, the original, the resize (which could be the same as original if you already resized it lower than whats in the Advanced settings before uploading), and the thumbnail. Right?

Thanks
Dixit

 
floridave
floridave's picture

Joined: 2003-12-22
Posts: 27300
Posted: Sat, 2011-10-08 00:26

Yes, but I would not count the original as a 'copy'

Dave
_____________________________________________
Blog & G2 || floridave - Gallery Team

 
nivekiam
nivekiam's picture

Joined: 2002-12-10
Posts: 16504
Posted: Sun, 2011-10-09 14:28

Another option would be to set the resize setting in G3 to be really small and create a new theme for your site that uses your originals instead of the resizes to be displayed.
____________________________________________
Like Gallery? Like the support? Donate now!

 
DixitS

Joined: 2009-10-08
Posts: 31
Posted: Sun, 2011-10-09 16:41

Thanks nivekiam. I guess you right without recoding the whole core side of the code, just set thre resize to like say 10pix or so.

Im going to look at the theme pages and see where it calls for resizes and see what it will take to redo them to look at the originals instead.

Dixit

 
nivekiam
nivekiam's picture

Joined: 2002-12-10
Posts: 16504
Posted: Sun, 2011-10-09 16:59

As a very, very quick and dirty start, edit /themes/wind/views/photo.html.php

replace:
<?= $item->resize_img(array("id" => "g-item-id-{$item->id}", "class" => "g-resize")) ?>

with:
<img src="<?=$item->file_url()?>">

That will replace loading the resize image with the full size image. However, you may still want to apply some CSS and probably remove some javascript to view the full size image when clicking on it :)
____________________________________________
Like Gallery? Like the support? Donate now!

 
DixitS

Joined: 2009-10-08
Posts: 31
Posted: Sun, 2011-10-09 17:03

Thanks a bunch. Going to play with this some and see what I come up with.

Dixit

 
DixitS

Joined: 2009-10-08
Posts: 31
Posted: Wed, 2011-10-12 02:12

I did end up figuring this out with some help from my brother (who better at HTML/CSS coding then I am).

Initially just replacing that line that nivekiam mentions, causes centering issues with the GreyDragon theme, cause he uses margins offsets based on the width of the resize_img which in my case is gone (cause I deleted it).

So what I did was create another funtion in the gallery3/modules/gallery/models/item.php. I basically copied the resize_img and modified it to point directly to the file_url

  /**
   * Return an <img> tag for the full image.
   * @param array $extra_attrs  Extra attributes to add to the img tag
   * @return string
   */
  public function full_img($extra_attrs) {
    $attrs = array_merge($extra_attrs,
            array("src" => $this->file_url(),
                  "alt" => $this->title)
            );
    // html::image forces an absolute url which we don't want
    return "<img" . html::attributes($attrs) . "/>";
  }

Then I modified two sections in the gallery3/themes/greydragon/views/photo.html.php

Change the the following line:

    <? $_resizewidth = $item->resize_width;

To the following line:

    <? $_resizewidth = $item->width;

This was done so it looks at the width of the actual image to fix the centering offset issue I was having.

Then I simply took the line (8lines below the above change) to:

           <?= $item->resize_img(array("id" => "g-photo-id-{$item->id}", "class" => "g-resize", "alt" => $_title)) ?>

To the following line:

           <?= $item->full_img(array("id" => "g-photo-id-{$item->id}", "class" => "g-resize", "alt" => $_title)) ?>

Which there I basically just changed the resize_img to full_img function I created earlier.

Im sure this can be applied to other themes in a similar manner with some tweaks.

Dixit