Login | Register For Free | Help
Search for: (Advanced)

Mailing List Archive: Bricolage: users

Imager, Thumbnails

 

 

Bricolage users RSS feed   Index | Next | Previous | View Threaded


david at kineticode

Mar 18, 2009, 8:18 PM

Post #1 of 18 (5305 views)
Permalink
Imager, Thumbnails

Hi All,

Can anyone give me a good reason not to require Imager.pm and to
enable USE_THUMBNAILS by default in 2.0?

I ask because I got tired of writing the same code over and over again
to create thumbnails for a site, so I've written a new method in
Bric::Biz::Asset::Business::Media::Image that encapsulates most of
what's in the old thumbnail.mc utility template:

http://www.bricolage.cc/templates/media/thumbnail.mc

With the new methods, which require Imager, of course, that template
can be rewritten as:

<%perl>
$burner->throw_error(q{That ain't no image})
unless ref($image) eq 'Bric::Biz::Asset::Business::Media::Image';
return $image->find_or_create_alternate({
title_prefix => $title_prefix,
title_suffix => $title_suffix,
file_prefix => $file_prefix,
file_suffix => $file_suffix,
et_key_name => $key_name,
use_thumbnail => 1,
});
</%perl>

You'll also be able to modify the image in any way you want. By
default, it will scale it just like Bricolage thumbnails (but why not
then just use Bricolage thumbnails?), but you can override that with
the "transform" callback, which lets you modify and return whatever
Imager object you like, like so:

return $image->find_or_create_alternate({
et_key_name => 'thumbnail',
transformer => sub {
shift->scale( xpixels =>115 )->crop( top => 76 );
}
});

Cute, eh? There will also be arguments that check the new media
document in once it's created, and to move it to a publish desk.

I think it's about time that we had full support for image
manipulation in the Bricolage core, don't you? That requires that we
require Imager -- and probably just enable thumbnails for everyone.

Any objections?

Best,

David


k.rudnik at gmail

Mar 19, 2009, 4:19 AM

Post #2 of 18 (5180 views)
Permalink
Re: Imager, Thumbnails [In reply to]

Great,

no objections at all but some questions just to make things clear (to me):
1. does et_key_name can have any value and thus let you use many
resized versions of an image at a time?
2. what happens if user reuploads a new version of original image;
hope that find_or_create_alternate rather recreates then finds an alternate?
3. I'd be nice if alternate media docs have dedicated media doc type;
you could then easily filter them out on media search page.
4. I wonder if newly created alternate docs should be moved to a publish desk.
In my case when an issue of the online journal contains dozens of
technical drawings
alternates make horrible mess on my publish desk and usually there is
nothing to do with them exept eventually pressing button.
They should be published automaticaly from templates so it'd be
perfect if they could be just checkin_and_shelve after creation.

5. (second life request) In my case all original technical pictures
are in eps format so Phillip's idea of alternate media containers
perfectly fits to my needs. Now I have to convert eps to png, upload
to bric but resizing png gives much worse results than resizing
original eps which are also uploaded to bric for archive reasons.
It' be perfect if for some other media docs types I could use core
find_or_create_alternate, flexible transformer callbacks and thumbnail
preview in gui.

Krzysztof




On Thu, Mar 19, 2009 at 4:18 AM, David E. Wheeler <david [at] kineticode> wrote:
> Hi All,
>
> Can anyone give me a good reason not to require Imager.pm and to enable
> USE_THUMBNAILS by default in 2.0?
>
> I ask because I got tired of writing the same code over and over again to
> create thumbnails for a site, so I've written a new method in
> Bric::Biz::Asset::Business::Media::Image that encapsulates most of what's in
> the old thumbnail.mc utility template:
>
>  http://www.bricolage.cc/templates/media/thumbnail.mc
>
> With the new methods, which require Imager, of course, that template can be
> rewritten as:
>
> <%perl>
> $burner->throw_error(q{That ain't no image})
>   unless ref($image) eq 'Bric::Biz::Asset::Business::Media::Image';
> return $image->find_or_create_alternate({
>   title_prefix  => $title_prefix,
>   title_suffix  => $title_suffix,
>   file_prefix   => $file_prefix,
>   file_suffix   => $file_suffix,
>   et_key_name   => $key_name,
>   use_thumbnail => 1,
> });
> </%perl>
>
> You'll also be able to modify the image in any way you want. By default, it
> will scale it just like Bricolage thumbnails (but why not then just use
> Bricolage thumbnails?), but you can override that with the "transform"
> callback, which lets you modify and return whatever Imager object you like,
> like so:
>
> return $image->find_or_create_alternate({
>   et_key_name  => 'thumbnail',
>   transformer  => sub {
>       shift->scale( xpixels =>115 )->crop( top => 76 );
>   }
> });
>
> Cute, eh? There will also be arguments that check the new media document in
> once it's created, and to move it to a publish desk.
>
> I think it's about time that we had full support for image manipulation in
> the Bricolage core, don't you? That requires that we require Imager -- and
> probably just enable thumbnails for everyone.
>
> Any objections?
>
> Best,
>
> David
>
>
>


paulo at digitalcraftsmen

Mar 19, 2009, 8:58 AM

Post #3 of 18 (5198 views)
Permalink
Re: Imager, Thumbnails [In reply to]

David E. Wheeler wrote:
> Hi All,
>
> Can anyone give me a good reason not to require Imager.pm and to enable
> USE_THUMBNAILS by default in 2.0?

+1 from me

--
Paul Orrock Digital Craftsmen
Lead SysAdmin www.digitalcraftsmen.net
Exmouth House, 3 Pine Street, London, EC1R 0JH
Tel: 020 7183 1410 Fax: 020 7099 5140


david at kineticode

Mar 19, 2009, 10:12 AM

Post #4 of 18 (5173 views)
Permalink
Re: Imager, Thumbnails [In reply to]

On Mar 19, 2009, at 4:19 AM, Krzysztof Rudnik wrote:

> no objections at all but some questions just to make things clear
> (to me):
> 1. does et_key_name can have any value and thus let you use many
> resized versions of an image at a time?

No, it's the key name for an element type that will be used to create
the new media object. If it's not supplied, it will be the same
element type as the current media document is based on.

> 2. what happens if user reuploads a new version of original image;
> hope that find_or_create_alternate rather recreates then finds an
> alternate?

Nope. The whole document model needs to be redesigned to handle this,
really. Or an event-driven plugin/callback architecture.

> 3. I'd be nice if alternate media docs have dedicated media doc type;
> you could then easily filter them out on media search page.

That's what et_key_name is for.

> 4. I wonder if newly created alternate docs should be moved to a
> publish desk.
> In my case when an issue of the online journal contains dozens of
> technical drawings
> alternates make horrible mess on my publish desk and usually there is
> nothing to do with them exept eventually pressing button.
> They should be published automaticaly from templates so it'd be
> perfect if they could be just checkin_and_shelve after creation.

I'm including a `move_to_pub` key, as well as `checkin` and `relate`.

> 5. (second life request) In my case all original technical pictures
> are in eps format so Phillip's idea of alternate media containers
> perfectly fits to my needs. Now I have to convert eps to png, upload
> to bric but resizing png gives much worse results than resizing
> original eps which are also uploaded to bric for archive reasons.
> It' be perfect if for some other media docs types I could use core
> find_or_create_alternate, flexible transformer callbacks and thumbnail
> preview in gui.

Yep, that should be do-able, as long as EPS and PNG support are
compiled into your build of Imager.

Best,

David


k.rudnik at gmail

Mar 19, 2009, 11:24 AM

Post #5 of 18 (5156 views)
Permalink
Re: Imager, Thumbnails [In reply to]

On Thu, Mar 19, 2009 at 6:12 PM, David E. Wheeler <david [at] kineticode> wrote:
> On Mar 19, 2009, at 4:19 AM, Krzysztof Rudnik wrote:
>
>> no objections at all but some questions just to make things clear (to me):
>> 1. does et_key_name can have any value and thus let you use many
>> resized versions of an image at a time?
>
> No, it's the key name for an element type that will be used to create the
> new media object. If it's not supplied, it will be the same element type as
> the current media document is based on.
So if I define 2 or more element types for that and use their names
as et_key_name value with suitable transformer callbacks when
find_or_create is called then it will do?
>
>> 2. what happens if user reuploads a new version of original image;
>> hope that find_or_create_alternate rather recreates then finds an
>> alternate?
>
> Nope. The whole document model needs to be redesigned to handle this,
> really. Or an event-driven plugin/callback architecture.
Well, I do belive (I must say) but my (working) template does exactly this job.
There is nothing magic in it so either I do some horrible mistake or
the problem is too deep for me.
The template is a compilation of two approches found in the list
alt_media.pl (so alt media docs are related to original media
document) and image_resize_and_relate (there are dedicated element
types for different sizes of image).
Template automatically refreshes alternates when original bitmap has changed.
I can send the code if anybody is interested.

Krzysztof


phillip at communitybandwidth

Mar 19, 2009, 11:28 AM

Post #6 of 18 (5179 views)
Permalink
Re: Imager, Thumbnails [In reply to]

On 19-Mar-09, at 3:24 PM, Krzysztof Rudnik wrote:

> I can send the code if anybody is interested.

Yep. :-)

--
Phillip Smith // Simplifier of Technology // COMMUNITY BANDWIDTH
www.communitybandwidth.ca // www.phillipadsmith.com


k.rudnik at gmail

Mar 19, 2009, 11:40 AM

Post #7 of 18 (5183 views)
Permalink
Re: Imager, Thumbnails [In reply to]

Ok,
I am just addind some <%docs> to the code and I'll post it when I am
ready (today)
k

On Thu, Mar 19, 2009 at 7:28 PM, Phillip Smith
<phillip [at] communitybandwidth> wrote:
>
> On 19-Mar-09, at 3:24 PM, Krzysztof Rudnik wrote:
>
>> I can send the code if anybody is interested.
>
> Yep.  :-)
>
> --
> Phillip Smith   //   Simplifier of Technology   //   COMMUNITY BANDWIDTH
> www.communitybandwidth.ca   //   www.phillipadsmith.com
>
>
>
>
>
>
>
>


david at kineticode

Mar 19, 2009, 6:50 PM

Post #8 of 18 (5175 views)
Permalink
Re: Imager, Thumbnails [In reply to]

On Mar 19, 2009, at 11:24 AM, Krzysztof Rudnik wrote:

> So if I define 2 or more element types for that and use their names
> as et_key_name value with suitable transformer callbacks when
> find_or_create is called then it will do?

I don't understand the question. Sorry.

> Well, I do belive (I must say) but my (working) template does
> exactly this job.
> There is nothing magic in it so either I do some horrible mistake or
> the problem is too deep for me.

Not too deep, just likely to require an ugly workaround.

> The template is a compilation of two approches found in the list
> alt_media.pl (so alt media docs are related to original media
> document) and image_resize_and_relate (there are dedicated element
> types for different sizes of image).
> Template automatically refreshes alternates when original bitmap has
> changed.
> I can send the code if anybody is interested.

Yeah, I'd like to take a look.

Best,

David


david at kineticode

Mar 20, 2009, 11:12 PM

Post #9 of 18 (5153 views)
Permalink
Re: Imager, Thumbnails [In reply to]

On Mar 18, 2009, at 11:18 PM, David E. Wheeler wrote:

> Can anyone give me a good reason not to require Imager.pm and to
> enable USE_THUMBNAILS by default in 2.0?
>
> I ask because I got tired of writing the same code over and over
> again to create thumbnails for a site, so I've written a new method
> in Bric::Biz::Asset::Business::Media::Image that encapsulates most
> of what's in the old thumbnail.mc utility template:
>
> http://www.bricolage.cc/templates/media/thumbnail.mc

Just to follow up on this message, folks. I checked in this change in
r8511.

http://marc.info/?l=bricolage-commits&m=123752394411242&q=p3

I then backported it to 1.10 and applied it to a client's server. This
client is creating a new site where every image can have up to two
thumbnail, one 195 x 73 and one 90 x 69. I implemented a utility
template to look up and generate these thumbnails like so:

my $thumb = $m->comp('/util/get_thumb.mc', for => $img, wide => 1);

Passing the "wide" parameter gives me a 195 x 73 image; otherwise i
get the 90 x 69. The great part, though, is that this is the entire
utility template:

~~~~~~~~~~~~~~~~~~~~~

<%args>
$for
$wide => 0
</%args>
<%perl>;
my ($suffix, $prefix, $width, $height) = $wide
? ( '_wide_thumb', 'Wide Thumb for ', 195, 73 )
: ( '_thumb', 'Thumb for ', 90, 69 );

my $thumb = eval {
$for->find_or_create_alternate({
title_prefix => $prefix,
file_suffix => $suffix,
et_key_name => 'thumbnail',
relate => 0,
transformer => sub {
shift->scale( xpixels => $width )->crop( height =>
$height );
}
});
};
return $thumb unless $@ && $burner->get_mode == PUBLISH_MODE;
$burner->throw_error(ref $@ ? $@->error : $@);
</%perl>

~~~~~~~~~~~~~~~~~~~~~

Isn't that a hell of a lot simpler than the old thumbnail.mc? If they
don't already exist, the new images are created, checked in, and moved
to a publish desk. And unlike with the old hacks, all the events are
properly logged and permissions properly checked (pass in a user
object from the template to have permissions checked for a different
user than the currently logged-in user.

I'm really pleased with this, because, aside from all the work of
writing the new `find_or_create_alternate()` method and a ton of tests
for it, writing the above template was dead easy. Now it almost feels
like there is real support for dynamically generating variations on
images in Bricolage. The only part that's hacky is the fact that we
still have to do this in templates (hence the funky error handling
above). The correct way to do this would be to have a real event-
driven callback architecture, not unlike what I've described here:

http://www.justatheory.com/bricolage/design/tasks_jobs_actions.html

Aside from that, the only other drawback I see to this implementation
is that, when the original image is updated, the thumbnails are not
regenerated. The callback architecture would solve that problem, too,
but I'll be curious to see what solution Krzysztof has come up with in
his templates.

Anyway, please check it out, those of you with thumbnail-triggering
templates, and let me know if it will make maintaing those templates
easier for you.

Best,

David


k.rudnik at gmail

Mar 21, 2009, 12:02 AM

Post #10 of 18 (5163 views)
Permalink
Re: Imager, Thumbnails [In reply to]

> Aside from that, the only other drawback I see to this implementation is
> that, when the original image is updated, the thumbnails are not
> regenerated. The callback architecture would solve that problem, too, but
> I'll be curious to see what solution Krzysztof has come up with in his
> templates.
I am cleaning up the code and testing.
(yesterday cleaned up too much... - that is the reason of the delay, sorry)

k

> Anyway, please check it out, those of you with thumbnail-triggering
> templates, and let me know if it will make maintaing those templates easier
> for you.
>
> Best,
>
> David
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>


david at kineticode

Mar 21, 2009, 7:20 AM

Post #11 of 18 (5166 views)
Permalink
Re: Imager, Thumbnails [In reply to]

On Mar 21, 2009, at 3:02 AM, Krzysztof Rudnik wrote:

>> Aside from that, the only other drawback I see to this
>> implementation is
>> that, when the original image is updated, the thumbnails are not
>> regenerated. The callback architecture would solve that problem,
>> too, but
>> I'll be curious to see what solution Krzysztof has come up with in
>> his
>> templates.
> I am cleaning up the code and testing.
> (yesterday cleaned up too much... - that is the reason of the delay,
> sorry)

Heh, I know how that goes. No problem, and thanks!

David


k.rudnik at gmail

Mar 22, 2009, 2:53 AM

Post #12 of 18 (5131 views)
Permalink
Re: Imager, Thumbnails [In reply to]

Ok,

This is my working utility template multi_illustration.mc that
finds or creates (use Image::Magick)
requested alternate versions of /jpeg/jpg/gif/png/ images.
If the original image bitmap has changed after reupload then
during the first run of this template that processes updated media
all existing alt versions are regenerated and republished if ->publishing.
After publishing fo the first story that updated media is related to
all pages on the publish server presenting any alt version of the orig image
show its updated alt versions.
So upload user action does not automaically regenerate thumbnais but
the first burn does.

Too detailed description inside.
The code is based on image_resize_and_relate.mc and alt_media.pl from this list.

I hope that someone will find it usable even if this approche does
not solve the problem
you mention below (if I understand it correctly)


pozdrawiam ;)

Krzysztof


On Sat, Mar 21, 2009 at 3:20 PM, David E. Wheeler <david [at] kineticode> wrote:
> On Mar 21, 2009, at 3:02 AM, Krzysztof Rudnik wrote:
>
>>> Aside from that, the only other drawback I see to this implementation is
>>> that, when the original image is updated, the thumbnails are not
>>> regenerated. The callback architecture would solve that problem, too, but
>>> I'll be curious to see what solution Krzysztof has come up with in his
>>> templates.
>>
>> I am cleaning up the code and testing.
>> (yesterday cleaned up too much... - that is the reason of the delay,
>> sorry)
>
> Heh, I know how that goes. No problem, and thanks!
>
> David
>
>


david at kineticode

Mar 22, 2009, 6:06 PM

Post #13 of 18 (5127 views)
Permalink
Re: Imager, Thumbnails [In reply to]

Looks like it didn't come through to the list. Can you attache it with
a ".txt" extension?

Thanks,

David

On Mar 22, 2009, at 5:53 AM, Krzysztof Rudnik wrote:

> Ok,
>
> This is my working utility template multi_illustration.mc that
> finds or creates (use Image::Magick)
> requested alternate versions of /jpeg/jpg/gif/png/ images.
> If the original image bitmap has changed after reupload then
> during the first run of this template that processes updated media
> all existing alt versions are regenerated and republished if -
> >publishing.
> After publishing fo the first story that updated media is related to
> all pages on the publish server presenting any alt version of the
> orig image
> show its updated alt versions.
> So upload user action does not automaically regenerate thumbnais but
> the first burn does.
>
> Too detailed description inside.
> The code is based on image_resize_and_relate.mc and alt_media.pl
> from this list.
>
> I hope that someone will find it usable even if this approche does
> not solve the problem
> you mention below (if I understand it correctly)
>
>
> pozdrawiam ;)
>
> Krzysztof
>
>
> On Sat, Mar 21, 2009 at 3:20 PM, David E. Wheeler <david [at] kineticode
> > wrote:
>> On Mar 21, 2009, at 3:02 AM, Krzysztof Rudnik wrote:
>>
>>>> Aside from that, the only other drawback I see to this
>>>> implementation is
>>>> that, when the original image is updated, the thumbnails are not
>>>> regenerated. The callback architecture would solve that problem,
>>>> too, but
>>>> I'll be curious to see what solution Krzysztof has come up with
>>>> in his
>>>> templates.
>>>
>>> I am cleaning up the code and testing.
>>> (yesterday cleaned up too much... - that is the reason of the delay,
>>> sorry)
>>
>> Heh, I know how that goes. No problem, and thanks!
>>
>> David
>>
>>


k.rudnik at gmail

Mar 23, 2009, 3:03 PM

Post #14 of 18 (5122 views)
Permalink
Re: Imager, Thumbnails [In reply to]

sorry,
txt now

K

On Mon, Mar 23, 2009 at 2:06 AM, David E. Wheeler <david [at] kineticode> wrote:
> Looks like it didn't come through to the list. Can you attache it with a
> ".txt" extension?
>
> Thanks,
>
> David
>
> On Mar 22, 2009, at 5:53 AM, Krzysztof Rudnik wrote:
>
>> Ok,
>>
>> This is my working utility template multi_illustration.mc  that
>> finds or creates (use Image::Magick)
>> requested alternate versions of  /jpeg/jpg/gif/png/ images.
>> If the original image bitmap has changed after reupload then
>> during the first run of this template that processes updated media
>> all existing alt versions are regenerated and republished if ->publishing.
>> After publishing fo the first story that updated media is related to
>> all pages on the publish server presenting any alt version of  the orig
>> image
>> show its  updated alt versions.
>> So upload user action does not automaically regenerate thumbnais but
>> the first burn does.
>>
>> Too detailed description inside.
>> The code is based on image_resize_and_relate.mc and alt_media.pl from this
>> list.
>>
>> I hope that someone will find it usable even if this approche  does
>> not solve the problem
>> you mention below (if I understand it correctly)
>>
>>
>> pozdrawiam ;)
>>
>> Krzysztof
>>
>>
>> On Sat, Mar 21, 2009 at 3:20 PM, David E. Wheeler <david [at] kineticode>
>> wrote:
>>>
>>> On Mar 21, 2009, at 3:02 AM, Krzysztof Rudnik wrote:
>>>
>>>>> Aside from that, the only other drawback I see to this implementation
>>>>> is
>>>>> that, when the original image is updated, the thumbnails are not
>>>>> regenerated. The callback architecture would solve that problem, too,
>>>>> but
>>>>> I'll be curious to see what solution Krzysztof has come up with in his
>>>>> templates.
>>>>
>>>> I am cleaning up the code and testing.
>>>> (yesterday cleaned up too much... - that is the reason of the delay,
>>>> sorry)
>>>
>>> Heh, I know how that goes. No problem, and thanks!
>>>
>>> David
>>>
>>>
>
>
Attachments: multi_illustration.txt (15.1 KB)


david at kineticode

Mar 24, 2009, 2:18 PM

Post #15 of 18 (5097 views)
Permalink
Re: Imager, Thumbnails [In reply to]

On Mar 23, 2009, at 6:03 PM, Krzysztof Rudnik wrote:

> sorry,
> txt now

Thanks got it.

>>> This is my working utility template multi_illustration.mc that
>>> finds or creates (use Image::Magick)
>>> requested alternate versions of /jpeg/jpg/gif/png/ images.
>>> If the original image bitmap has changed after reupload then
>>> during the first run of this template that processes updated media
>>> all existing alt versions are regenerated and republished if -
>>> >publishing.
>>> After publishing fo the first story that updated media is related to
>>> all pages on the publish server presenting any alt version of the
>>> orig
>>> image
>>> show its updated alt versions.
>>> So upload user action does not automaically regenerate thumbnais but
>>> the first burn does.

Right.

>>> Too detailed description inside.

Which I partially quote and comment on below. :-) BTW, you'll still be
able to do all this in 2.0, though you may or may not also want to use
the new method I added last week.

>>> The code is based on image_resize_and_relate.mc and alt_media.pl
>>> from this
>>> list.
>>>
>>> I hope that someone will find it usable even if this approche does
>>> not solve the problem
>>> you mention below (if I understand it correctly)

Maybe it should be added to the wiki? Is that where we keep example
templates these days?

So, to quote from your docs:

> The code is based on image_resize_and_relate.mc with the following
> differences/enchancements:
>
> 1. Image media documents that allow alternate versions must have
> dedicated type (for example multiillustration)

Yes, structurally, that's a good idea.

> 2. Alternate media documents containing resized versions of original
> image get related to the original
> media document instead of story document.
> multiillustration elem. type must accept subelement types (with
> related madia enabled),
> one for each alternate version you want use.

I thought about doing this. I also thought about relating the
thumbnails to the original. I still might do that, now that I think
about it, because it makes it even easier to look for existing
thumbnails. It won't help with autopublish, though.

> 4. All newly created alt media documents have URIs that do not
> depend on orig media file name:
> It is of the form
> ${orig_media_doc_uri_path}/${alt_media_common_prefix}_$
> {orig_media_doc_id}_$postfix.$ext
> so it does not change when user reuploads orig media bitmap
> unless image format has changed ($ext has changed then)
> or MEDIA...UNIQUE_FILE_NAME is enabled in conf. In the last case
> template will probably not work without modification.

Right.

> 5. When alternate image version is requested than the template
> searches for a suitable alt media document.
> If search has failed then
> a. new alt media document is created,
> b. resized image version is generated and uploaded,
> c. orig media image fs path is stored in alt media description
> field.
> d. a container dedicated for that alt version is created and
> added to the orig media doc
> e. newly created alt media document gets related to this container
> Note: fs path contains image version number so it changes
> whenever user reuploads a new image to the orig media document.
>
> If search has been successful then alt media document
> description field
> is compared to the orig media doc image fs path.
> If they are nor equal then alt image is regenerated, reuploaded and
> orig media image fs path is stored in desc field again

I was wondering how you were able to tell when an image had changed.
The use of the description field is a decent hack, albeit user-visible.

> 6. Whenever story is published than all atl media docs it refers to
> are also republished if ->needs_publish happens.

Right, that's the benefit of properly establishing the relationships.
Note that it depends on the `PUBLISH_RELATED_ASSETS` bricolage.conf
directive being enabled, which it is by default. Note that this auto-
publishing feature is not a part of the find_or_create_alternate()
method unless you pass `relate => 1` (which is passed by default). I
made it optional because I currently have a client who needs two
thumbnails for every image. I need to think more about how I can
remedy this situation.

> A side effect: if you don't use orig image URIs on your pages
> (just alternate ones as in my case)
> then after the first publish of any story that orig media (with
> reuploaded bitmap) is related to
> all pages on your publish server which show these alternates do
> show their uptodate versions (without republishing!).

Right, because the URL never changes. This is a feature.

> I am not quite sure if this a feature or !feature. In the later
> case it may be easily corrected by changing the way
> in which alt media docs URIs are generated below.

Feature, unless I'm misunderstanding you.

> 7. Only required alternate versions are created (not all
> admissible ones) but
> if orig media image has changed before then all previousely
> created alt versions
> are out of date then they are refreshed (and republished if -
> >publishing).

How do they get refreshed unless a story that relates to the original
is republished? You're not using media document templates, are you?
That would require a patch, and I'm not sure anyone has made such a
patch available.

> 8. this code is not PUBLISH_MODE safe - it throws_errors without
> hesitation.

Heh. I'm tempted to do that all the time.

BTW:

> use Image::Magick;

You should put that in PERL_LOADER and save yourself some overhead.

Best,

David


david at kineticode

Mar 24, 2009, 2:18 PM

Post #16 of 18 (5107 views)
Permalink
Re: Imager, Thumbnails [In reply to]

On Mar 23, 2009, at 6:03 PM, Krzysztof Rudnik wrote:

> sorry,
> txt now

Thanks got it.

>>> This is my working utility template multi_illustration.mc that
>>> finds or creates (use Image::Magick)
>>> requested alternate versions of /jpeg/jpg/gif/png/ images.
>>> If the original image bitmap has changed after reupload then
>>> during the first run of this template that processes updated media
>>> all existing alt versions are regenerated and republished if -
>>> >publishing.
>>> After publishing fo the first story that updated media is related to
>>> all pages on the publish server presenting any alt version of the
>>> orig
>>> image
>>> show its updated alt versions.
>>> So upload user action does not automaically regenerate thumbnais but
>>> the first burn does.

Right.

>>> Too detailed description inside.

Which I partially quote and comment on below. :-) BTW, you'll still be
able to do all this in 2.0, though you may or may not also want to use
the new method I added last week.

>>> The code is based on image_resize_and_relate.mc and alt_media.pl
>>> from this
>>> list.
>>>
>>> I hope that someone will find it usable even if this approche does
>>> not solve the problem
>>> you mention below (if I understand it correctly)

Maybe it should be added to the wiki? Is that where we keep example
templates these days?

So, to quote from your docs:

> The code is based on image_resize_and_relate.mc with the following
> differences/enchancements:
>
> 1. Image media documents that allow alternate versions must have
> dedicated type (for example multiillustration)

Yes, structurally, that's a good idea.

> 2. Alternate media documents containing resized versions of original
> image get related to the original
> media document instead of story document.
> multiillustration elem. type must accept subelement types (with
> related madia enabled),
> one for each alternate version you want use.

I thought about doing this. I also thought about relating the
thumbnails to the original. I still might do that, now that I think
about it, because it makes it even easier to look for existing
thumbnails. It won't help with autopublish, though.

> 4. All newly created alt media documents have URIs that do not
> depend on orig media file name:
> It is of the form
> ${orig_media_doc_uri_path}/${alt_media_common_prefix}_$
> {orig_media_doc_id}_$postfix.$ext
> so it does not change when user reuploads orig media bitmap
> unless image format has changed ($ext has changed then)
> or MEDIA...UNIQUE_FILE_NAME is enabled in conf. In the last case
> template will probably not work without modification.

Right.

> 5. When alternate image version is requested than the template
> searches for a suitable alt media document.
> If search has failed then
> a. new alt media document is created,
> b. resized image version is generated and uploaded,
> c. orig media image fs path is stored in alt media description
> field.
> d. a container dedicated for that alt version is created and
> added to the orig media doc
> e. newly created alt media document gets related to this container
> Note: fs path contains image version number so it changes
> whenever user reuploads a new image to the orig media document.
>
> If search has been successful then alt media document
> description field
> is compared to the orig media doc image fs path.
> If they are nor equal then alt image is regenerated, reuploaded and
> orig media image fs path is stored in desc field again

I was wondering how you were able to tell when an image had changed.
The use of the description field is a decent hack, albeit user-visible.

> 6. Whenever story is published than all atl media docs it refers to
> are also republished if ->needs_publish happens.

Right, that's the benefit of properly establishing the relationships.
Note that it depends on the `PUBLISH_RELATED_ASSETS` bricolage.conf
directive being enabled, which it is by default. Note that this auto-
publishing feature is not a part of the find_or_create_alternate()
method unless you pass `relate => 1` (which is passed by default). I
made it optional because I currently have a client who needs two
thumbnails for every image. I need to think more about how I can
remedy this situation.

> A side effect: if you don't use orig image URIs on your pages
> (just alternate ones as in my case)
> then after the first publish of any story that orig media (with
> reuploaded bitmap) is related to
> all pages on your publish server which show these alternates do
> show their uptodate versions (without republishing!).

Right, because the URL never changes. This is a feature.

> I am not quite sure if this a feature or !feature. In the later
> case it may be easily corrected by changing the way
> in which alt media docs URIs are generated below.

Feature, unless I'm misunderstanding you.

> 7. Only required alternate versions are created (not all
> admissible ones) but
> if orig media image has changed before then all previousely
> created alt versions
> are out of date then they are refreshed (and republished if -
> >publishing).

How do they get refreshed unless a story that relates to the original
is republished? You're not using media document templates, are you?
That would require a patch, and I'm not sure anyone has made such a
patch available.

> 8. this code is not PUBLISH_MODE safe - it throws_errors without
> hesitation.

Heh. I'm tempted to do that all the time.

BTW:

> use Image::Magick;

You should put that in PERL_LOADER and save yourself some overhead.

Best,

David


k.rudnik at gmail

Mar 25, 2009, 12:15 PM

Post #17 of 18 (5104 views)
Permalink
Re: Imager, Thumbnails [In reply to]

Thanks for the reply,


>
>>>> This is my working utility template multi_illustration.mc  that
>>>> finds or creates (use Image::Magick)
>>>> requested alternate versions of  /jpeg/jpg/gif/png/ images.
>>>> If the original image bitmap has changed after reupload then
>>>> during the first run of this template that processes updated media
>>>> all existing alt versions are regenerated and republished if
>>>> ->publishing.
>>>> After publishing fo the first story that updated media is related to
>>>> all pages on the publish server presenting any alt version of  the orig
>>>> image
>>>> show its  updated alt versions.
>>>> So upload user action does not automaically regenerate thumbnais but
>>>> the first burn does.
>
> Right.
>
>>>> Too detailed description inside.
>
> Which I partially quote and comment on below. :-) BTW, you'll still be able
> to do all this in 2.0, though you may or may not also want to use the new
> method I added last week.
I've been using this template (on my devel install) for 2. weeks or so
(since I've managed to teach my bric regular TeXing) and it seems
to be very "user-energy-efficient"
- no garbage thumb media generation when updating orig image,
- (semi)automatic regeneration
- easy update/refresh media usecase


I can't try your core method now cos :( I don't know how to upgrade my
bric instance to the
newest trunk version. (I upgraded 1.11.1 to svn version a month ago
with make upgrade but I can't repeat it - need some reading).
I'll try as soon as I can since thumb management is going very hard task
in my site [.hundreds images from 10 year's archive with criptic file names etc.
= very big chance to keep making mistakes one after another ]

BTW, what is a scenario when user notices that media image is wrong and
have to be updated?
- manualy find all thumbs delete them and republish all stories that
relate to updated media?

> Maybe it should be added to the wiki? Is that where we keep example
> templates these days?
I' will
>


> I thought about doing this. I also thought about relating the thumbnails to
> the original. I still might do that, now that I think about it, because it
> makes it even easier to look for existing thumbnails.
Right!!


>
> Right, that's the benefit of properly establishing the relationships. Note
> that it depends on the `PUBLISH_RELATED_ASSETS` bricolage.conf directive
> being enabled, which it is by default. Note that this auto-publishing
> feature is not a part of the find_or_create_alternate() method unless you
> pass `relate => 1` (which is passed by default). I made it optional because
> I currently have a client who needs two thumbnails for every image. I need
> to think more about how I can remedy this situation.
>
>>   A side effect: if you don't use orig image URIs on your pages (just
>> alternate ones as in my case
>>   then after the first publish of any  story that orig media (with
>> reuploaded bitmap) is related to
>>   all pages on your publish server which show these alternates do show
>> their  uptodate versions (without republishing!).
>
> Right, because the URL never changes. This is a feature.
>
>>   I am not quite sure if this a feature or !feature. In the later case it
>> may be easily corrected by changing the way
>>   in which alt media docs URIs are generated below.
>
> Feature, unless I'm misunderstanding you.
My hesitation to call it a feature follows from the fact that if
updated thumb has new sizes (height) then there might be a mess
on unpublished pages showing a new thumb version if you hardcoded
thumb height in html. But this is a minor problem, I suppose.

>
>>   7. Only required alternate versions are created (not all admissible
>> ones) but
>>   if orig media image has changed before then all previousely created alt
>> versions
>>   are out of date then they are refreshed (and republished if
>> ->publishing).
>
> How do they get refreshed unless a story that relates to the original is
> republished? You're not using media document templates, are you? That would
> require a patch, and I'm not sure anyone has made such a patch available.
They don't, you must republish just one story that relates to the original.
If this is going to be a problem for me I'll probably use poor's man
method that I can figure now.
= run cron job that finds updated orig media that ->needs_publish,
relates them to a dummy/textless story worker,
and publish that story (hope this is possible and easy)

Thanks again for your comments.

Krzysztof


>
> Best,
>
> David
>


david at kineticode

Mar 25, 2009, 7:03 PM

Post #18 of 18 (5100 views)
Permalink
Re: Imager, Thumbnails [In reply to]

On Mar 25, 2009, at 3:15 PM, Krzysztof Rudnik wrote:

> I can't try your core method now cos :( I don't know how to upgrade my
> bric instance to the
> newest trunk version. (I upgraded 1.11.1 to svn version a month ago
> with make upgrade but I can't repeat it - need some reading).

Should be pretty much the same. We'll do 1.11.2 soonish, as well.

> I'll try as soon as I can since thumb management is going very hard
> task
> in my site [.hundreds images from 10 year's archive with criptic file
> names etc.
> = very big chance to keep making mistakes one after another ]
>
> BTW, what is a scenario when user notices that media image is wrong
> and
> have to be updated?
> - manualy find all thumbs delete them and republish all stories that
> relate to updated media?

Only if the file name has changed, which I don't recommend.

> My hesitation to call it a feature follows from the fact that if
> updated thumb has new sizes (height) then there might be a mess
> on unpublished pages showing a new thumb version if you hardcoded
> thumb height in html. But this is a minor problem, I suppose.

Yes, I would either not code the height and width into the HTML, or
use a standard size that will never change.

>> How do they get refreshed unless a story that relates to the
>> original is
>> republished? You're not using media document templates, are you?
>> That would
>> require a patch, and I'm not sure anyone has made such a patch
>> available.
> They don't, you must republish just one story that relates to the
> original.
> If this is going to be a problem for me I'll probably use poor's man
> method that I can figure now.
> = run cron job that finds updated orig media that ->needs_publish,
> relates them to a dummy/textless story worker,
> and publish that story (hope this is possible and easy)

Yeah, should be.

Best,

David

Bricolage users RSS feed   Index | Next | Previous | View Threaded
 
 


Interested in having your list archived? Contact Gossamer Threads
 
  Web Applications & Managed Hosting Powered by Gossamer Threads Inc.