Module: Rebuild items

floridave
floridave's picture

Joined: 2003-12-22
Posts: 27300
Posted: Mon, 2010-07-26 05:03

http://codex.gallery2.org/Gallery3:Modules:rebuild_items

A module that marks items as 'dirty' in the database and lets Gallery rebuild those items, on a per album basis, via the admin section.

If you experience issues with gallery not rebuilding items, please start a new thread.

Dave
_____________________________________________
Blog & G2 || floridave - Gallery Team

 
bharat
bharat's picture

Joined: 2002-05-21
Posts: 7994
Posted: Sat, 2010-07-31 21:04

Woot! Nice one, Dave.
---
Problems? Check gallery3/var/logs
bugs/feature req's | upgrade to the latest code | use git

 
webmalone

Joined: 2007-03-06
Posts: 30
Posted: Tue, 2010-08-10 22:15

Dave, I tried using this module today to repair several broken and new touched up images. I uploaded the new original image to the appropriate /var/album directory and then performed the repair on that album. It worked for the thumbnails, but not for the "resized" images.

Color corrected in Picasa ... thumb and large image looks good, but the "resized" image did not change and is still the old dark gray color (new ones have a rich black): http://egrips.com/gallery/promo/sports/UlsterSpecialTredz

Same scenario as above
http://egrips.com/gallery/promo/sports/GoldsGym_Proof2

Same scenario as above
http://egrips.com/gallery/promo/sports/Suns_GoSuns_Proof1

Same scenario as above, but this new image was also cropped much tighter, as the original had a bunch of white space below it, which you can still see in the "resized" version.
http://egrips.com/gallery/promo/sports/Card-Hanshin-Tigersx5

Hopefully I did something wrong, but I checked all the boxes to make all versions "dirty".

I'm hopeful this module takes the place of the G2 "ReUpload" module.

Thanks for your work!
Matt

 
floridave
floridave's picture

Joined: 2003-12-22
Posts: 27300
Posted: Tue, 2010-08-10 22:29
Quote:
but I checked all the boxes to make all versions "dirty".

Only the first task in the list that is checked will be performed.
So you have to visit the module again from the album options and then check the re-sizes box not the thumbs box.

Dave
_____________________________________________
Blog & G2 || floridave - Gallery Team

 
webmalone

Joined: 2007-03-06
Posts: 30
Posted: Tue, 2010-08-10 22:48

:) in deed ... so the first 3 are now fixed and look much better ... these were only color corrected and kept the same size.

The last photo was also cropped to a smaller dimension. It's thumb and re-sized photo look great and reflect all the changes of the "new" original, but the enlarged image is distorted, and still enlarges to the old dimensions of the original file ... stretched in both directions.

http://egrips.com/gallery/promo/sports/Card-Hanshin-Tigersx5

Matt

 
floridave
floridave's picture

Joined: 2003-12-22
Posts: 27300
Posted: Wed, 2010-08-11 01:39
 
webmalone

Joined: 2007-03-06
Posts: 30
Posted: Wed, 2010-08-11 02:25

Not a cache issue ... 3 different cleared out browsers, and 3 different computers, all same result.

The database shows the original size as well, so the Rebuild Items module isn't updating the items table with the new Original image size during the rebuild.

1420 x 699 is the size of new original image

1600 x 1126 is the size in the database, and the size of the stretched-out image space, when you click the "resized" image. Also the enlarged image is below the viewing area and you have to scroll down to see it.

 
floridave
floridave's picture

Joined: 2003-12-22
Posts: 27300
Posted: Wed, 2010-08-11 03:03

Did you change the original item?
If you did then this is not the module for you.
I'm now a bit confused as to what you have done.
A new thread should have been started but since we are down this road already we can carry on.

Dave

_____________________________________________
Blog & G2 || floridave - Gallery Team

 
webmalone

Joined: 2007-03-06
Posts: 30
Posted: Wed, 2010-08-11 03:20

Yes, as stated in my original post, I updated the original item (via ftp), then ran the module. I don't know what's under the covers, but it's very close to being exactly what I need (and hoped) it would do. There is no other way, that I know of, to update an image without totally deleting it, and all the tags, and descriptions (starting from scratch), in G3 ....... but this is very close!

Do you see what I'm describing when you click the resized image?

 
floridave
floridave's picture

Joined: 2003-12-22
Posts: 27300
Posted: Wed, 2010-08-11 03:43

I now understand what you are after.
A new different module could probably be developed but is not in the scope of this module.

Dave
_____________________________________________
Blog & G2 || floridave - Gallery Team

 
webmalone

Joined: 2007-03-06
Posts: 30
Posted: Wed, 2010-08-11 04:10

Thanks Dave! It's still a great module and EXTREMELY useful to us, just not when original items have been cropped / dimensions change.

I appreciate your 18,539th post!

 
glodakan
glodakan's picture

Joined: 2010-06-13
Posts: 51
Posted: Fri, 2010-08-13 17:23

hello dave :)
its maybe great module for my gallery or this module can fix my problem in here http://gallery.menalto.com/node/96957
or you have suggestion to fix this problem my gallery :)

Thank you very much,
Regards,

Putra

 
crackers

Joined: 2002-10-24
Posts: 67
Posted: Thu, 2010-11-18 17:03

it is possible to add a feature to this?

The ability to include all sub-albums would be great.

Thanks

 
sykong

Joined: 2006-04-07
Posts: 21
Posted: Sat, 2011-01-01 09:35

The rebuild items option is available to those with edit permissions, but I think it only works if you have admin permissions? This results in a "Dang... Something went wrong!" page instead.

Would be good to not show the option if the user is not an admin, or display a page explaining that admin rights are required.

 
floridave
floridave's picture

Joined: 2003-12-22
Posts: 27300
Posted: Wed, 2011-01-05 01:43

sykong,
Thanks for the report, I have fixed the module in the fist post.

Dave
_____________________________________________
Blog & G2 || floridave - Gallery Team

 
floridave
floridave's picture

Joined: 2003-12-22
Posts: 27300
Posted: Sat, 2011-02-05 07:11

Updated the module to try to detect thumbs/resizes that did not get generated properly during upload.
It compares the thumb/resize size against the size of the item in the DB and you can rebuild/mark dirty those items only.

see first post for new version.

Dave
_____________________________________________
Blog & G2 || floridave - Gallery Team

 
tempg

Joined: 2005-12-17
Posts: 1857
Posted: Tue, 2011-04-05 16:08

@floridave: Many thanks for this module!!

I think that the exif module pulls the keywords from the exif data and posts them to the database as tags when initially uploading images. When rebuilding exif using the module, the tags don't get updated. I don't know if anyone else noticed (or cares), but it may be useful to note somewhere that the tags don't get updated.

Also, I noticed that the module only executes the first of the checked boxes; maybe they could just be radio buttons (so you can only select one)?

 
tempg

Joined: 2005-12-17
Posts: 1857
Posted: Tue, 2011-04-05 18:33

Now I'm seeing that the module picks up new data, but not updated data. (Example: If a caption is added to a photo that previously had one, it will be updated; if a caption is changed/modified for a photo, the new caption is not picked up.)

Is this expected behavior or is something on this end interfering with the module?

 
floridave
floridave's picture

Joined: 2003-12-22
Posts: 27300
Posted: Wed, 2011-04-06 00:38
Quote:
Also, I noticed that the module only executes the first of the checked boxes; maybe they could just be radio buttons (so you can only select one)?

I wanted to use radio buttons but the Kohana/forge form builder we use does not have radio buttons.... or at least ones that work the way radio buttons are expected to work. If you see a forge/Kohana method let me know. I could change it to a drop-down but I thought that the text would be good enough. But as we all know not everybody reads or is just click happy.

Dave
_____________________________________________
Blog & G2 || floridave - Gallery Team

 
tempg

Joined: 2005-12-17
Posts: 1857
Posted: Wed, 2011-04-06 00:43

Wow. I didn't know about the radio limitation. (That also changes what I said at http://gallery.menalto.com/node/99842#comment-371960 )
And I was one of the non-reading, click-happy people when I first used the module. Lol.
I agree that the text is fine as is.

 
floridave
floridave's picture

Joined: 2003-12-22
Posts: 27300
Posted: Wed, 2011-04-06 00:42
tempg wrote:
Now I'm seeing that the module picks up new data, but not updated data. (Example: If a caption is added to a photo that previously had one, it will be updated; if a caption is changed/modified for a photo, the new caption is not picked up.)

Is this expected behavior or is something on this end interfering with the module?

Not sure I follow. Can you give a user story? The module was really developed as a last resort for those who have hosts that kill processes during the upload process and we/Kohana don't throw a exception to stopped processes in this case.

Dave

_____________________________________________
Blog & G2 || floridave - Gallery Team

 
tempg

Joined: 2005-12-17
Posts: 1857
Posted: Wed, 2011-04-06 00:50

I upload a photos with captions but discover some error that requires I change all of the original captions. I edit the captions offline and replace the original photos in my var/albums directory. I then run the rebuild items module, resetting exif data and going through the maintenance task. I'll find that the original captions are still there; they have not been replaced by the new ones.

Given the original intent, this may be outside the scope of the module. For me, the module's been a big help replacing images with smaller, web-optimized versions. I was also trying to use it to modify all of the exif captions and to update all the associated tags. (I didn't want to do this via "edit photo" for each photo because I want the new captions to be available in the original photo so that it's also searchable locally.)

Hope that makes sense; got a little wordy.

 
undagiga

Joined: 2010-11-26
Posts: 693
Posted: Wed, 2011-04-06 01:42

This may be of interest to me, since I am about to do some replacements. I wonder if the captions and tags were cleared from the DB before the rebuild then perhaps it might pick up the new caption. If this is the case then there should be a query that does this. Perhaps also the logic could be built into the module. If this works for the caption then it should also work for tags.

U-G

 
floridave
floridave's picture

Joined: 2003-12-22
Posts: 27300
Posted: Sat, 2011-04-09 20:04

All this module does is mark dirty the item then the maintenance task is run to fix that.
I don't think that this module should delete the data in the data field of the EXIF table for the item.
It starts to get complex really quick here for my skill set.
A new module could be developed to do this. I will ramble here for a bit....
If you replace a item with different EXIF/IPTC data and want it to be populated then other things have to happen as well....
The EXIF module populates the title and description field as well as the tags. Say you re-upload an item and some of the other fields change..
Should the old tags be removed? Should the title of the item now take the title from the new re-uploaded image what about the description?
I think this is such a small use case that it might not be worth the effort to make sure all the different ramifications of screwing with the the DB even more.
I can help somebody that might use this module as a starting point but don't feel that the extra coding and checking and a good UI to go with is is worth the effort.

Would just deleting the data field be good enough?
Thoughts?

Dave
_____________________________________________
Blog & G2 || floridave - Gallery Team

 
undagiga

Joined: 2010-11-26
Posts: 693
Posted: Sun, 2011-04-10 04:00

I agree that it's hard to justify spending time on something that's used only infrequently. However when it's needed then you miss it.

I prefer to manage my images in a Digital Asset Management (DAM) program and upload images with metadata already included and have G3 import this information. Occasionally I find errors in my captioning and tagging and would like to upload the corrected version. But at the moment it seems like it's hard to get G3 to pick up the new information if I simply overwrite the version in the albums folder and run rebuild.

Greydragon has an option to mark items as "dirty" and as well has an option to reload EXIF. Yet it doesn't pick up edited captions and tags either. I might ask Serge about that first if I can't work out why. The advantage of the module is that it provides targeted rebuilding, whereas the Greygragon option is DB-wide, which is ok for me at this stage but isn't an option you'd want to run all that often on larger databases.

I will comment further once I've had time to do a little digging.

U-G

 
floridave
floridave's picture

Joined: 2003-12-22
Posts: 27300
Posted: Sun, 2011-04-10 05:27
Quote:
But at the moment it seems like it's hard to get G3 to pick up the new information if I simply overwrite the version in the albums folder and run rebuild.

If it is such a rare occasion then why not delete the original item and re-add it? Seems to me that writing a module for a rare occasion when a perfectly good work around is available seems like a waste of time. Don't get me wrong, if there was a real need for this then I am all for it, I just don't see a real need for it. If your process of adding meta data is flawed then I don't think that Gallery should be to tool to fix that.

Quote:
isn't an option you'd want to run all that often on larger databases

Perhaps another more targeted module is in order?

Dave
_____________________________________________
Blog & G2 || floridave - Gallery Team

 
floridave
floridave's picture

Joined: 2003-12-22
Posts: 27300
Posted: Sun, 2011-04-10 05:30

Let's start a new thread with your specific requirements and work flow. So as not to distract from this thread.

Dave
_____________________________________________
Blog & G2 || floridave - Gallery Team

 
undagiga

Joined: 2010-11-26
Posts: 693
Posted: Sun, 2011-04-10 06:11

Ok, but first I want to correct something I said in this thread. I must have done something wrong in the past, because I just tried it again and it worked. If I re-upload an image with a changed caption, and then in Greydragon I tell it to mark the EXIF as "dirty", and then in maintenance I reimport the EXIF, I get the new caption. Your module is better because I don't have to run it for the entire gallery. It's a really neat module for these situations.

The relevant code (in Greydragon) seems to be:

          db::update('exif_records')
            ->set(array('dirty'=>'1'))
            ->execute();

And I'm wondering if something similar could be done for tags. If I want to pursue this I will start a new thread.

U-G

 
floridave
floridave's picture

Joined: 2003-12-22
Posts: 27300
Posted: Sun, 2011-04-10 14:35

Looks like the same to me:

			db::build()
			  ->update("exif_records")
			  ->set("dirty", 1)
              ->where("item_id", "=", $form_id)
              ->execute();

except I only do it for the specific item
or where I get the items in the album as well:

        db::build()
          ->update("exif_records")
          ->set("dirty", 1)
          ->where("item_id", "in", db::build()->select("id")->from("items")->where("parent_id", "=", $album_id))
          ->execute();

Dave
_____________________________________________
Blog & G2 || floridave - Gallery Team

 
undagiga

Joined: 2010-11-26
Posts: 693
Posted: Sun, 2011-04-10 23:25

Yes, that's right. I didn't make that clear. You are doing the same thing. What I was wondering was whether it's possible to use this sort of code to mark tags as dirty in order to trigger some sort of rebuild. I used Serge's code as an example simply because it is slightly simpler.

U-G

 
floridave
floridave's picture

Joined: 2003-12-22
Posts: 27300
Posted: Thu, 2011-04-21 22:06

undagiga,
can you post a url to 2 images that have the original and then the changes you make to the EXIF/IPTC info.

Dave
_____________________________________________
Blog & G2 || floridave - Gallery Team

 
floridave
floridave's picture

Joined: 2003-12-22
Posts: 27300
Posted: Thu, 2011-04-21 22:09

We only chnage the caption if the caption is blank. If the caption is not empty we don't change the caption. This prevents the EXIF/IPTC fields overriding the existing data supplied by the User-interface ( edit item ).

Dave
_____________________________________________
Blog & G2 || floridave - Gallery Team

 
undagiga

Joined: 2010-11-26
Posts: 693
Posted: Fri, 2011-04-22 03:39

I'll send you a PM with some sample images, but first I want to be sure that I understand what you want to see. You want to see two images, one with that has had the caption changed via an EXIF rebuild, and one that hasn't - is that right? What exactly will this tell you?

U-G

 
floridave
floridave's picture

Joined: 2003-12-22
Posts: 27300
Posted: Fri, 2011-04-22 04:25

I would like 2 4 images. One that was the one you added to G3 and one that has the edited info that you manually added later.
Another pair of images with a title not-in/in the EXIF/IPTC data would be usefull as well.

Dave
_____________________________________________
Blog & G2 || floridave - Gallery Team

 
undagiga

Joined: 2010-11-26
Posts: 693
Posted: Fri, 2011-04-22 06:37

I'm not sure that we're on the same wavelength, but perhaps we are. I haven't "manually" added any information. All my images have IPTC pre-populated before I upload them, so that Title, Description and Tags are automatically imported. In the case of "Title" this requires a well documented hack as IPTC isn't imported to title in the base code. In a few cases I have subsequently changed the image including its IPTC and uploaded it directly to the albums folder overwriting the existing copy, marked it as "dirty" and also the EXIF as "dirty" and run the maintenance tasks. My recollection is that the caption was updated (but not the tags).

So what I propose to do is create two test images, upload and import them (server add). I will then change the IPTC for one of them and overwrite the image in the albums folder. Is this alright? Do you want me also to run the rebuild tasks on it or not?

All my images have titles, so for the second pair, you only need an additional one without the title? Actually this is going to be trickier, as I have added to the import hack for titles so that G3 merges two IPTC fields for the image title - IPTC Object Name and IPTC Source. I guess I can ensure that both these fields are blank.

I'm happy to help as always, but want to make sure I understand.

U-G

p.s. I'm happy with the current behaviour for title and caption and wouldn't want to see it change. I.e. they are only reimported from EXIF if EXIF is marked as "dirty". This makes it easy for me to maintain metadata outside of G3 and keep it sync via upload and EXIF rebuild. My issue is only with tags - I'd like to be able to do the same with them.

 
floridave
floridave's picture

Joined: 2003-12-22
Posts: 27300
Posted: Fri, 2011-04-22 14:54

What I want is a clear use case so I understand what is happening and what is not.

Quote:
My issue is only with tags - I'd like to be able to do the same with them.

Then tell me a user story and send me the before and after photos for this.

Dave

_____________________________________________
Blog & G2 || floridave - Gallery Team

 
floridave
floridave's picture

Joined: 2003-12-22
Posts: 27300
Posted: Fri, 2011-04-22 15:27

https://github.com/gallery/gallery3/commit/99fd65ff02d17cbb3ec936b4bdbf2a8c6b0b73e3
See if that fixes your issue.

Dave
_____________________________________________
Blog & G2 || floridave - Gallery Team

 
undagiga

Joined: 2010-11-26
Posts: 693
Posted: Sat, 2011-04-23 07:30

First a clarification. I've been doing some systematic testing and I've realised that what I said above is wrong (again). If I upload a replacement image with a different IPTC Caption, then the G3 description is not updated. As you suggest, there is a test whether the caption is blank, and if it it isn't then it isn't replaced.

What happened in my previous testing was that I had changed the "IPTC Object Name" and the G3 title was updated. This occurred because I inserted the hack to import object name into title outside of the test for whether the field is blank or not, and so it's always reimported.

Now if I want to change the behaviour for caption I can see how to do that - looks fairly easy. What I can't see is how to change the behaviour for tags, so that different IPTC Keywords in a replacement image leads to different G3 tags.

The latest release didn't fix the problem. I'll PM you a URL with test images.

U-G

 
floridave
floridave's picture

Joined: 2003-12-22
Posts: 27300
Posted: Sat, 2011-04-23 13:35

I think I understand now. The tags module is on the list to add some features like editing/combining tag names so I am a bit reluctant to do any work on that untill that is done.
I will put it on my list of thing to do. Thanks for the detail in your PM.

Dave
_____________________________________________
Blog & G2 || floridave - Gallery Team

 
undagiga

Joined: 2010-11-26
Posts: 693
Posted: Sat, 2011-04-23 14:37

I understand why you want to move cautiously, but some pointers as to where I might look to hack the code in the meantime would be helpful.

Thanks.

U-G

 
undagiga

Joined: 2010-11-26
Posts: 693
Posted: Thu, 2011-05-26 02:00

I embarrassed to admit that the release of 3.0.2 passed me by. I don't know how this happened. It looks like it was over Easter, so perhaps I was distracted.

I see that there was: "Added support for splitting and joining tags". Does this mean that rebuilding tags via this module is now feasible? If so, is this something that someone of my coding abilities could attempt?

I ask because with the release of the Tag Albums module we have the chance to create virtual albums. I need to insert new tags and for me it is safest and most efficient to do this offline in my database and then re-upload to var/albums.

Thanks

U-G

 
floridave
floridave's picture

Joined: 2003-12-22
Posts: 27300
Posted: Thu, 2011-05-26 02:15
Quote:
Does this mean that rebuilding tags via this module is now feasible?

Don't know never tried. Give it a try and report back.
With virtual albums I have not tried that yet either. There is only so many hours in the day.

Dave

_____________________________________________
Blog & G2 || floridave - Gallery Team

 
undagiga

Joined: 2010-11-26
Posts: 693
Posted: Thu, 2011-05-26 02:18
floridave wrote:
There is only so many hours in the day.

Ain't that the truth.

I'd be glad to hear from anyone with any tips on how to do this.

U-G

 
floridave
floridave's picture

Joined: 2003-12-22
Posts: 27300
Posted: Fri, 2012-04-27 19:43

Updated the module to gather tags from the item as well.

Dave
_____________________________________________
Blog & G2 || floridave - Gallery Team

 
rpabel

Joined: 2006-12-05
Posts: 6
Posted: Sun, 2012-06-03 13:44

Hi,
I've implemented re-scanning all items for new tags in an album by a simple db query and then calling your rebuild_item::get_tags() for each item found. Works for me (tm).
Patch should be attached.
Sincerely,
Roland

 
rpabel

Joined: 2006-12-05
Posts: 6
Posted: Sun, 2012-06-03 13:56

Addendum to my last post: The "items" table contains everything including the albums (I thought it contained only images), so the database query should include

->where("type", "=", "photo")

or some similar measure...
Roland

 
floridave
floridave's picture

Joined: 2003-12-22
Posts: 27300
Posted: Sun, 2012-06-03 23:01

Thanks for the patch.
I have updated this module to version 6 with your changes.

Dave
_____________________________________________
Blog & G2 || floridave - Gallery Team

 
sykong

Joined: 2006-04-07
Posts: 21
Posted: Sun, 2012-12-23 03:55

I guess this might be more of a feature request, but is there a way to mark all oversized images and thumbnails as dirty? (And automatically rebuild without having to give my photographers admin access?)

 
tempg

Joined: 2005-12-17
Posts: 1857
Posted: Tue, 2013-01-01 17:13
sykong wrote:
without having to give my photographers admin access?

Not sure what the relationship is between you and the photographers; not sure of the relationship between the photographers and the website. The request sounds a bit complicated and likely not a good idea for the average user (because then anyone could potentially rebuild images at any time: drains system resources and could also cause issues if more than one person attempted at a time on same photos). Maybe I'm misunderstanding?

Why do the individual photographers need to rebuild the images of albums they don't have permissions on? Perhaps there's another solution that works?

 
floridave
floridave's picture

Joined: 2003-12-22
Posts: 27300
Posted: Tue, 2013-01-01 22:03
webmalone wrote:
There is no other way, that I know of, to update an image without totally deleting it, and all the tags, and descriptions (starting from scratch)

There is now: http://codex.gallery2.org/Gallery3:Modules:replace

_____________________________________________
Blog & G2 || floridave - Gallery Team

 
floridave
floridave's picture

Joined: 2003-12-22
Posts: 27300
Posted: Tue, 2013-01-01 22:06

sykong
Perhaps you need to find the reason why the items need to be rebuilt. A resource issue perhaps? This is now a module that should be used very often. If you users add items and they don't get built when they are added that is what you should focus on to get fixed.

Dave
_____________________________________________
Blog & G2 || floridave - Gallery Team