Changed all images sizes to tuples. fileinfo.rpy does not need any
changes. freevo_config.py is already using tuple.
Index: src/www/htdocs/library.rpy
===================================================================
--- src/www/htdocs/library.rpy (revision 8895)
+++ src/www/htdocs/library.rpy (working copy)
@@ -603,29 +603,30 @@
new_height = float(height) * (float(new_width) / float(width))
except ZeroDivisionError:
new_height = 200
- return [int(new_width), int(new_height + 0.5)]
+ return (int(new_width), int(new_height + 0.5))
def get_fit_to_square_size(self, size, new_size):
print 'get_fit_to_square_size(self, size=%s, new_size=%s)' %
(str(size), str(new_size))
try:
- scaled_size = [new_size[0], new_size[1]]
- ### if aspect ratio > 1 then scale width
+ scaled_width = new_size[0]
+ scaled_height = new_size[1]
+ ### if aspect ratio > 1 then scale height
if size[0] > size[1]:
- scaled_size[1] = new_size[0] * size[1] / size[0]
- ### else scale height to 200
+ scaled_height = scaled_width * size[1] / size[0]
+ ### else scale width
else:
- scaled_size[0] = new_size[1] * size[0] / size[1]
+ scaled_width = scaled_height * size[0] / size[1]
except ZeroDivisionError:
pass
- return scaled_size
+ return (scaled_width, scaled_height)
def get_scaled_image_and_size(self, filepath, size):
'''
Returns the location of a scaled image and size of the scaled image
- as a 2-tuple. Eg. ("/var/cache/freevo/test.jpg", [200, 150]).
- The image will be scaled only if it larger than a certain prefixed
- size. May be in future the prefixed image size could be a config
- variable.
+ as a 2-tuple. Eg. ("/var/cache/freevo/test.jpg", (200, 150)).
+ The image will be scaled only if it larger than the threshold size
+ in config.WWW_IMAGE_THRESHOLD_SIZE. The scaled size will be limited
+ to the boundaries of config.WWW_IMAGE_THUMBNAIL_SIZE
'''
print 'get_scaled_image_and_size(self, filepath=%r, size=%s)'
% (filepath, str(size))
threshold_size = config.WWW_IMAGE_THRESHOLD_SIZE
On 1/1/07, Chandan Pitta <[EMAIL PROTECTED]> wrote:
> On 1/1/07, Duncan Webb <[EMAIL PROTECTED]> wrote:
> > Chandan Pitta wrote:
> > > On 1/1/07, Duncan Webb <[EMAIL PROTECTED]> wrote:
> > >> Chandan Pitta wrote:
> > >>> Hi Duncan,
> > >>>
> > >>
> > >> I'm wondering about this line, why is a + ".jpg" at the end of the line?
> > >>
> > >> scaled_image_path = self.cache_dir + filepath.replace("/",
> > >> "_").replace(".", "_") + ".jpg"
> > >
> > > For some reason imlib was having problems if the file name has a dot
> > > anywhere else except than the extension. For example
> > > my_trip1_10.10.2006.jpg is having problems. The only way I could avoid
> > > it was to covert the dots to underscores but then imlib also wanted an
> > > extension and would not write to my_trip1_10_10_2006_jpg, so I decided
> > > to add ".jpg" at the end. I guess it could have been done more
> > > elegantly by ripping out extension, converting to underscore and then
> > > re-attaching the extension, but did not bother.
> >
> > I'm wondering about non-jpeg images, haven't tried png's for example.
>
> I did not try with png either but I tried .gif files and they are
> simply converted to scaled jpg images. I am pretty sure other formats
> will work the same way. This is what I got
>
> file
> /var/cache/freevo/image_cache/_home_chandanp_pictures_cartoons_Dilbert_2006_06_21_gif.jpg
>
> /var/cache/freevo/image_cache/_home_chandanp_pictures_cartoons_Dilbert_2006_06_21_gif.jpg:
> JPEG image data, JFIF standard 1.01
>
>
> >
> > >> It was you patch with, but using:
> > >> new_image = image.scale_preserve_aspect(config.WWW_IMAGE_THUMBNAIL_SIZE)
> > >> Which means that resize_image_to_square could go, but I see we need this.
> > >>
> > >> This means that I can now change freevo cache to create these images.
> > >> And this means that the library.rpy need to read the cached image size.
> > >> I'll let you know when this is done.
> > >
> > > Excellent!
> >
> > Already done :)
>
> You are quick. As I said Excellent ;-)
>
> >
> > >> kaa.imlib2 uses tuples for sizes, so we should stick to tuples for the
> > >> sizes too. I haven't done these changes.
> > >
> > > Yes using tuples makes sense, but how many files are affected? I think
> > > I can take a look at library.rpy but I guess there may be several
> > > places where code needs to be changed.
> >
> > Not very many places, just library.rpy and maybe fileinfo.rpy
>
> I will take a look, so don't bother. You can review once I submit the patch.
>
>
> >
> > >> The other stuff was just a few extra prints, which are not needed.
> > >>
> > >>> Coming to the issue with your images from cache not showing up, did
> > >>> you patch the webserver.py with the patch I sent? Basically it this
> > >>> line available in src/helpers/webserver.py?
> > >>>
> > >>> root.putChild(config.FREEVO_CACHEDIR.replace("/", "_"),
> > >>> static.File(config.FREEVO_CACHEDIR))
> > >> I missed this, as I had already done the changes, almost exactly the
> > >> same as you, so the patch was rejected. :(
> > >
> > > Interesting. I am using the latest svn and everything is working fine.
> > > I even changed WEBSERVER_CACHEDIR to a different location and tested
> > > and it seems to be working fine. Can you do a quick test to see if
> > > twisted recognized the child resource by trying something like
> > > http://localhost:<your_port>/_home_chandanp_temp/ in your browser.
> > > Replace _home_chandanp_temp with what ever your WEBSERVER_CACHEDIR is
> > > pointing to (do a print in __init__ of library.rpy or somewhere just
> > > to be sure) with all "/" replaced with "_". You should be able to see
> > > the folder listing (if twisted has permission to that folder). If you
> > > see "404 - No Such Resource", then it is a problem with twisted.
> >
> > I'm slowly getting the idea :)
> >
> > I had missed some more lines from the patch, quite often parts are
> > rejected. Good to do an svn update, to check for conflicts and gzip
> > patches by email.
>
> Hope you were able to figure out what went wrong.
>
> >
> > > A very happy and prosperous new year to you and all. Hope Freevo will
> > > see a new level of sophistication.
> >
> > Happy new year to you too. Freevo has jumped a bit over the last few
> > months, mainly to people like you sending in patches and plug ins.
> > >
> > >> The last revision is now 8889.
> >
> > Now 8894, with web changes.
> >
> > Duncan
> >
> >
> > -------------------------------------------------------------------------
> > Take Surveys. Earn Cash. Influence the Future of IT
> > Join SourceForge.net's Techsay panel and you'll get the chance to share your
> > opinions on IT & business topics through brief surveys - and earn cash
> > http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV
> > _______________________________________________
> > Freevo-devel mailing list
> > [email protected]
> > https://lists.sourceforge.net/lists/listinfo/freevo-devel
> >
>
-------------------------------------------------------------------------
Take Surveys. Earn Cash. Influence the Future of IT
Join SourceForge.net's Techsay panel and you'll get the chance to share your
opinions on IT & business topics through brief surveys - and earn cash
http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV
_______________________________________________
Freevo-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/freevo-devel