Image upload and serve

classic Classic list List threaded Threaded
9 messages Options
Reply | Threaded
Open this post in threaded view
|

Image upload and serve

Colin O'Brien
Hi

I want to add to our application for a user to upload an image to the  
server file system and in the confirmation page see an auto-generated  
thumbnail of that image.

The upload and save seem to be working.
(Does that mean
https://forge.objectweb.org/tracker/index.php?
func=detail&aid=302653&group_id=168&atid=350210
is fixed?)

At first, I could not get the image serve to work at all.
Interestingly, the image server example on orbeon.com also fails to  
display an image.
I downloaded the latest build and ran the example locally and it did  
work.
That meant it must be my code after all, and I eventually tracked the  
problem down to the way I had the protocol  in the  
config/image-directory element (wrong number of slashes on file: - you  
can have one, three or four, but not two).

What I am still struggling with is caching.
If I put any value it seems into config/cache/directory then I get an  
NPE in computeCacheFileName (line 478).
(If I add the element and leave it empty, I get my thumbnail but I  
don't seem to get a cached file)
This happens whether I put <path-encoding> as flat (which is what I  
think I want) or hierarchical.

Anyone any ideas on what I might be doing wrong?

Thanks & regards
Colin




--
You receive this message as a subscriber of the [hidden email] mailing list.
To unsubscribe: mailto:[hidden email]
For general help: mailto:[hidden email]?subject=help
ObjectWeb mailing lists service home page: http://www.objectweb.org/wws
Reply | Threaded
Open this post in threaded view
|

Re: Image upload and serve

Erik Bruchez
Administrator
Colin O'Brien wrote:

 > The upload and save seem to be working.
 > (Does that mean
 >
https://forge.objectweb.org/tracker/index.php?func=detail&aid=302653&group_id=168&atid=350210 

 > is fixed?)

Yes, that was fixed a while ago. I just closed it, thanks.

 > At first, I could not get the image serve to work at all.
 > Interestingly, the image server example on orbeon.com also fails to
 > display an image.

 > I downloaded the latest build and ran the example locally and it did
 > work.

That was just fixed in the code on Friday, actually! Now working
online too.

 > That meant it must be my code after all, and I eventually tracked
 > the problem down to the way I had the protocol in the
 > config/image-directory element (wrong number of slashes on file: -
 > you can have one, three or four, but not two).

Good.

 > What I am still struggling with is caching.
 > If I put any value it seems into config/cache/directory then I get an
 > NPE in computeCacheFileName (line 478).
 > (If I add the element and leave it empty, I get my thumbnail but I don't
 > seem to get a cached file)
 > This happens whether I put <path-encoding> as flat (which is what I
 > think I want) or hierarchical.

I can reproduce the problem. Bug entry to track it:

http://forge.objectweb.org/tracker/index.php?func=detail&aid=304492&group_id=168&atid=350207

-Erik




--
You receive this message as a subscriber of the [hidden email] mailing list.
To unsubscribe: mailto:[hidden email]
For general help: mailto:[hidden email]?subject=help
ObjectWeb mailing lists service home page: http://www.objectweb.org/wws
Reply | Threaded
Open this post in threaded view
|

Re: Image upload and serve

Colin O'Brien
Hi Erik

thanks for the update.

Since I can't try it right now, can I check that it will do what I want?
I'm assuming that the cached file will have the same file  
name.extension as the original, it just sits in a separate cache  
directory
(and yes, I will be have use-sandbox as false)

Best regards
Colin

On Jan 16, 2006, at 7:07 PM, Erik Bruchez wrote:

> Colin O'Brien wrote:
>
> > The upload and save seem to be working.
> > (Does that mean
> >  
> https://forge.objectweb.org/tracker/index.php?
> func=detail&aid=302653&group_id=168&atid=350210
> > is fixed?)
>
> Yes, that was fixed a while ago. I just closed it, thanks.
>
> > At first, I could not get the image serve to work at all.
> > Interestingly, the image server example on orbeon.com also fails to
> > display an image.
>
> > I downloaded the latest build and ran the example locally and it did
> > work.
>
> That was just fixed in the code on Friday, actually! Now working
> online too.
>
> > That meant it must be my code after all, and I eventually tracked
> > the problem down to the way I had the protocol in the
> > config/image-directory element (wrong number of slashes on file: -
> > you can have one, three or four, but not two).
>
> Good.
>
> > What I am still struggling with is caching.
> > If I put any value it seems into config/cache/directory then I get an
> > NPE in computeCacheFileName (line 478).
> > (If I add the element and leave it empty, I get my thumbnail but I  
> don't
> > seem to get a cached file)
> > This happens whether I put <path-encoding> as flat (which is what I
> > think I want) or hierarchical.
>
> I can reproduce the problem. Bug entry to track it:
>
> http://forge.objectweb.org/tracker/index.php?
> func=detail&aid=304492&group_id=168&atid=350207
>
> -Erik
>
>
>
> --
> You receive this message as a subscriber of the  
> [hidden email] mailing list.
> To unsubscribe: mailto:[hidden email]
> For general help: mailto:[hidden email]?subject=help
> ObjectWeb mailing lists service home page: http://www.objectweb.org/wws



--
You receive this message as a subscriber of the [hidden email] mailing list.
To unsubscribe: mailto:[hidden email]
For general help: mailto:[hidden email]?subject=help
ObjectWeb mailing lists service home page: http://www.objectweb.org/wws
Reply | Threaded
Open this post in threaded view
|

Re: Image upload and serve

Erik Bruchez
Administrator
Colin O'Brien wrote:
> Hi Erik
>
> thanks for the update.
>
> Since I can't try it right now, can I check that it will do what I want?
> I'm assuming that the cached file will have the same file name.extension
> as the original, it just sits in a separate cache directory
> (and yes, I will be have use-sandbox as false)

File names are of the form:

ca-coast.jpg-82433486a875fcf1d4dc012b2c219688

where the trailer represents the transformations that have been applie
to the image.

-Erik



--
You receive this message as a subscriber of the [hidden email] mailing list.
To unsubscribe: mailto:[hidden email]
For general help: mailto:[hidden email]?subject=help
ObjectWeb mailing lists service home page: http://www.objectweb.org/wws
Reply | Threaded
Open this post in threaded view
|

Re: Image upload and serve

Colin O'Brien

On Jan 17, 2006, at 4:30 PM, Erik Bruchez wrote:

> Colin O'Brien wrote:
>> Hi Erik
>> thanks for the update.
>> Since I can't try it right now, can I check that it will do what I
>> want?
>> I'm assuming that the cached file will have the same file
>> name.extension as the original, it just sits in a separate cache
>> directory
>> (and yes, I will be have use-sandbox as false)
>
> File names are of the form:
>
> ca-coast.jpg-82433486a875fcf1d4dc012b2c219688
>
> where the trailer represents the transformations that have been applie
> to the image.
>
> -Erik
Any way we can have an option to just have the original
filename.extension?

What I was hoping to do was:
* to have the site owner upload an image
* use the imageserver to create the thumbnail for the owner to review
* for subsequent visitors to the site, serve the thumbnail image
directly from the cache directory using apache2

Hence the need for a smple/predictable name.

Thanks & regards
Colin




--
You receive this message as a subscriber of the [hidden email] mailing list.
To unsubscribe: mailto:[hidden email]
For general help: mailto:[hidden email]?subject=help
ObjectWeb mailing lists service home page: http://www.objectweb.org/wws
Reply | Threaded
Open this post in threaded view
|

Re: Image upload and serve

Erik Bruchez
Administrator
Colin O'Brien wrote:

>
> On Jan 17, 2006, at 4:30 PM, Erik Bruchez wrote:
>
>> Colin O'Brien wrote:
>>> Hi Erik
>>> thanks for the update.
>>> Since I can't try it right now, can I check that it will do what I want?
>>> I'm assuming that the cached file will have the same file
>>> name.extension as the original, it just sits in a separate cache
>>> directory
>>> (and yes, I will be have use-sandbox as false)
>>
>> File names are of the form:
>>
>> ca-coast.jpg-82433486a875fcf1d4dc012b2c219688
>>
>> where the trailer represents the transformations that have been applie
>> to the image.
>>
>> -Erik
>
> Any way we can have an option to just have the original filename.extension?
It's not that easy, as the cache may have to store several version of
the same image. Just imagine that "california.jpg" is resized in
640x400: the cache has to store that resized version, and make sure that
if somebody asks for the same image resized in 32x20, the correct
version is produced from the cache. So more information than just the
file name must be stored, which is why we augment the original file name.

We chose the option to use a hash value instead of something more
transparent is for reasons of coding simplicity and extensibility, as
there are many transformations you can do with the Image Server, such as
cropping, resizing, but also some drawing operations.

> What I was hoping to do was:
> * to have the site owner upload an image
> * use the imageserver to create the thumbnail for the owner to review
> * for subsequent visitors to the site, serve the thumbnail image
> directly from the cache directory using apache2
>
> Hence the need for a smple/predictable name.

I think what is needed here is a way to obtain the cached file name from
the Image Server, but that would require writing some Java code.

Anyway, the first things to do will be to fix that NPE bug!

-Erik



--
You receive this message as a subscriber of the [hidden email] mailing list.
To unsubscribe: mailto:[hidden email]
For general help: mailto:[hidden email]?subject=help
ObjectWeb mailing lists service home page: http://www.objectweb.org/wws
Reply | Threaded
Open this post in threaded view
|

Re: Image upload and serve

Colin O'Brien
Hi Erik
On Jan 18, 2006, at 5:47 AM, Erik Bruchez wrote:

> Colin O'Brien wrote:
>> On Jan 17, 2006, at 4:30 PM, Erik Bruchez wrote:
>>> Colin O'Brien wrote:
>>>> Hi Erik
>>>> thanks for the update.
>>>> Since I can't try it right now, can I check that it will do what I
>>>> want?
>>>> I'm assuming that the cached file will have the same file
>>>> name.extension as the original, it just sits in a separate cache
>>>> directory
>>>> (and yes, I will be have use-sandbox as false)
>>>
>>> File names are of the form:
>>>
>>> ca-coast.jpg-82433486a875fcf1d4dc012b2c219688
>>>
>>> where the trailer represents the transformations that have been
>>> applie to the image.
>>>
>>> -Erik
>> Any way we can have an option to just have the original
>> filename.extension?
>
> It's not that easy, as the cache may have to store several version of
> the same image. Just imagine that "california.jpg" is resized in
> 640x400: the cache has to store that resized version, and make sure
> that if somebody asks for the same image resized in 32x20, the correct
> version is produced from the cache. So more information than just the
> file name must be stored, which is why we augment the original file
> name.
What you say is true for the general situation, where perhaps, as in
your example app, the user is in control of the image transformation.

In a more specific situation such as mine, none of that is relevant
because the app is in control and is only ever going to ask for the one
transformation. (Or if I did find the need for more than one, I would
put them in separate cache directories).

I think this is analogous to the use-cache option - you wouldn't let a
site user set that option, but it is there for apps that know what they
are doing and for whom it is relevant.

> We chose the option to use a hash value instead of something more
> transparent is for reasons of coding simplicity and extensibility, as
> there are many transformations you can do with the Image Server, such
> as cropping, resizing, but also some drawing operations.
>
>> What I was hoping to do was:
>> * to have the site owner upload an image
>> * use the imageserver to create the thumbnail for the owner to review
>> * for subsequent visitors to the site, serve the thumbnail image
>> directly from the cache directory using apache2
>> Hence the need for a smple/predictable name.
>
> I think what is needed here is a way to obtain the cached file name
> from the Image Server, but that would require writing some Java code.
>
> Anyway, the first things to do will be to fix that NPE bug!
Well, obviously I agree with that, but it won't make the processor
useful for me.
Let me explain some more of where this will be used.
As I said, the site owner will be the one to initiate the thumbnail
generation by uploading the original.
So only one transformation is happening at a time (per site).
When the site visitor sees the thumbnail, it will be on a page of many
thumbnails.
So a number of image requests will hit the server at the same time.
The idea of caching is to reduce load on the server obviously, but
having finished thumbnails available for Apache to server will be even
more efficient than having them served by Tomcat after the OPS app has
checked whether it needs to regenerate the image.

Simply adding an option to the processor config as you say might not be
the only way to address this use case. It does seem cleaner than having
to return and store a new filename. Either way, I hope we can find
something that will work for most people.

Thanks & regards
Colin





--
You receive this message as a subscriber of the [hidden email] mailing list.
To unsubscribe: mailto:[hidden email]
For general help: mailto:[hidden email]?subject=help
ObjectWeb mailing lists service home page: http://www.objectweb.org/wws
Reply | Threaded
Open this post in threaded view
|

Re: Image upload and serve

Colin O'Brien
Oops, should have said analogous to use-sandbox, not use-cache.

>
> What you say is true for the general situation, where perhaps, as in
> your example app, the user is in control of the image transformation.
>
> In a more specific situation such as mine, none of that is relevant
> because the app is in control and is only ever going to ask for the
> one transformation. (Or if I did find the need for more than one, I
> would put them in separate cache directories).
>
> I think this is analogous to the use-cache option - you wouldn't let a
> site user set that option, but it is there for apps that know what
> they are doing and for whom it is relevant.
>
> Let me explain some more of where this will be used.
> As I said, the site owner will be the one to initiate the thumbnail
> generation by uploading the original.
> So only one transformation is happening at a time (per site).
> When the site visitor sees the thumbnail, it will be on a page of many
> thumbnails.
> So a number of image requests will hit the server at the same time.
> The idea of caching is to reduce load on the server obviously, but
> having finished thumbnails available for Apache to server will be even
> more efficient than having them served by Tomcat after the OPS app has
> checked whether it needs to regenerate the image.
>
> Simply adding an option to the processor config as you say might not
> be the only way to address this use case. It does seem cleaner than
> having to return and store a new filename. Either way, I hope we can
> find something that will work for most people.
>
> Thanks & regards
> Colin
>
>
>
>
> --
> You receive this message as a subscriber of the
> [hidden email] mailing list.
> To unsubscribe: mailto:[hidden email]
> For general help: mailto:[hidden email]?subject=help
> ObjectWeb mailing lists service home page: http://www.objectweb.org/wws



--
You receive this message as a subscriber of the [hidden email] mailing list.
To unsubscribe: mailto:[hidden email]
For general help: mailto:[hidden email]?subject=help
ObjectWeb mailing lists service home page: http://www.objectweb.org/wws
Reply | Threaded
Open this post in threaded view
|

Re: Image upload and serve

Erik Bruchez
Administrator
In reply to this post by Colin O'Brien
Colin O'Brien wrote:

> So a number of image requests will hit the server at the same time.
> The idea of caching is to reduce load on the server obviously, but
> having finished thumbnails available for Apache to server will be even
> more efficient than having them served by Tomcat after the OPS app has
> checked whether it needs to regenerate the image.
>
> Simply adding an option to the processor config as you say might not be
> the only way to address this use case. It does seem cleaner than having
> to return and store a new filename. Either way, I hope we can find
> something that will work for most people.
The idea of course makes sense. The best I can do at this point is to
open an RFE:

http://forge.objectweb.org/tracker/index.php?func=detail&aid=304547&group_id=168&atid=350210

-Erik



--
You receive this message as a subscriber of the [hidden email] mailing list.
To unsubscribe: mailto:[hidden email]
For general help: mailto:[hidden email]?subject=help
ObjectWeb mailing lists service home page: http://www.objectweb.org/wws