Sorry attached the wrong diff file. See this one

On 1/2/07, Chandan Pitta <[EMAIL PROTECTED]> wrote:
Hi Duncan,

Here is another patch (hopefully the last one) that fixes the following issues:
* Images with spaces in the filename or in the directories are not
being displayed properly (see Wout's issue)
* Since the WWW_IMAGE_THUMBNAIL_SIZE is a tuple of 2 values, I decided
to change get_fit_to_square_size() to get_fit_to_rectangle_size()
which makes more sense if a user wants to fit images in a specific
rectangular area (see Ryan's issue).
* I fixed the issue where you mentioned that converting PNG files may
have issues (or loose value) if they are converted to JPGs. The fix
basically uses the same extension except for GIF (reasons follow
below)

While fixing issue 3 I found that imlib has problems scaling (a file
is not created and I do not see any exceptions) a file if
1. The file has .gif extension. So for .gif files, I scale the image
with .jpg extension attached to it.
2. I found that files with extension in capital (eg. .JPG instead of
.jpg) are not scaled by imlib. I have several files with .JPG
extensions and they are not created by imlib.save(). So I decided to
change them to lower case. Not sure if it happens to all file
extensions or specifically to jpgs.

If you know why I am seeing these issues let me know.

Chandan


On 1/2/07, Chandan Pitta <[EMAIL PROTECTED]> wrote:
> It should be (100, 100).
>
>
> On 1/2/07, Ryan Roth <[EMAIL PROTECTED]> wrote:
> > o should it be set to ( 100, 100 ) or just ( 100 ) ?
> >
> > Chandan Pitta wrote:
> > > Hello Ryan,
> > >
> > > It seems to be working for me. I am wondering if you are expecting all
> > > your images to be scaled to 100 x 75. If that is true than the
> > > assumption is wrong. The webserver currently expects the thumbnail
> > > size to be a square so you should be using 100x100. And all your
> > > images will be scaled to fit in that square while maintaining aspect
> > > ratio. If you want the images to fit to the rectangle instead (while
> > > maintaining aspect ratio) then try this patch.
> > >
> > > Index: src/www/htdocs/library.rpy
> > > ===================================================================
> > > --- src/www/htdocs/library.rpy  (revision 8911)
> > > +++ src/www/htdocs/library.rpy  (working copy)
> > > @@ -605,13 +605,13 @@
> > >              new_height = 200
> > >          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))
> > > +    def get_fit_to_rectangle_size(self, size, new_size):
> > > +        print 'get_fit_to_rectangle_size(self, size=%s, new_size=%s)'
> > > % (str(size), str(new_size))
> > >          try:
> > >              scaled_width = new_size[0]
> > >              scaled_height = new_size[1]
> > > -            ### if aspect ratio > 1 then scale height
> > > -            if size[0] > size[1]:
> > > +            ### if actual image aspect ratio > scaled image aspect
> > > ratio then scale height
> > > +            if float(size[0]) / size[1] > float(scaled_width) / 
scaled_height:
> > >                  scaled_height = scaled_width * size[1] / size[0]
> > >              ### else scale width
> > >              else:
> > > @@ -631,7 +631,7 @@
> > >          print 'get_scaled_image_and_size(self, filepath=%r, size=%s)'
> > > % (filepath, str(size))
> > >          threshold_size = config.WWW_IMAGE_THRESHOLD_SIZE
> > >          new_size = config.WWW_IMAGE_THUMBNAIL_SIZE
> > > -        new_size = self.get_fit_to_square_size(size, new_size)
> > > +        new_size = self.get_fit_to_rectangle_size(size, new_size)
> > >          scaled_image_path = self.cache_dir + filepath.replace("/",
> > > "_").replace(".", "_") + ".jpg"
> > >
> > >          # if the size of image falls below threshold size then use
> > > original image
> > >
> > > Thanks
> > > Chandan
> > >
> > >
> > >
> > > On 1/2/07, Ryan Roth <[EMAIL PROTECTED]> wrote:
> > >
> > >> I have WWW_IMAGE_THUMBNAIL_SIZE = (100, 75) set in my local_conf, but I
> > >> don't seethat it is doing anything.  Do I have it set right?
> > >>
> > >> Thanks
> > >>
> > >>
> > >> -------------------------------------------------------------------------
> > >> 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
> > >
> > >
> >
> > -------------------------------------------------------------------------
> > 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
> >
>



Index: src/www/htdocs/library.rpy
===================================================================
--- src/www/htdocs/library.rpy  (revision 8911)
+++ src/www/htdocs/library.rpy  (working copy)
@@ -465,7 +465,7 @@
                     ### show image
                     if action_mediatype == "images":
                         size = (info['width'], info['height'])
-                        (scaled_image, new_size) = 
self.get_scaled_image_and_size(filepath, size)
+                        (scaled_image, new_size) = 
self.get_scaled_image_and_size(item, size)
                         image_link = self.convert_dir(filepath)
                         fv.tableCell('<a 
href="javascript:openfoto(\''+image_link+'\','+str(size[0])+','+str(size[1])+')">'\
                             +'<img src="'+scaled_image+'" 
height="'+str(new_size[1])+'px" width="'+str(new_size[0])+'px" />'\
@@ -605,13 +605,13 @@
             new_height = 200
         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))
+    def get_fit_to_rectangle_size(self, size, new_size):
+        print 'get_fit_to_rectangle_size(self, size=%s, new_size=%s)' % 
(str(size), str(new_size))
         try:
             scaled_width = new_size[0]
             scaled_height = new_size[1]
-            ### if aspect ratio > 1 then scale height
-            if size[0] > size[1]:
+            ### if actual image aspect ratio > scaled image aspect ratio then 
scale height
+            if float(size[0]) / size[1] > float(scaled_width) / scaled_height:
                 scaled_height = scaled_width * size[1] / size[0]
             ### else scale width
             else:
@@ -631,8 +631,12 @@
         print 'get_scaled_image_and_size(self, filepath=%r, size=%s)' % 
(filepath, str(size))
         threshold_size = config.WWW_IMAGE_THRESHOLD_SIZE
         new_size = config.WWW_IMAGE_THUMBNAIL_SIZE
-        new_size = self.get_fit_to_square_size(size, new_size)
-        scaled_image_path = self.cache_dir + filepath.replace("/", 
"_").replace(".", "_") + ".jpg"
+        new_size = self.get_fit_to_rectangle_size(size, new_size)
+        file_ext_index = filepath.rindex(".")
+        file_ext = filepath[file_ext_index:].lower()
+        if file_ext.lower() == ".gif":
+            file_ext += ".jpg"
+        scaled_image_path = self.cache_dir + 
filepath[:file_ext_index].replace("/", "_") + file_ext

         # if the size of image falls below threshold size then use original 
image
         if size[0] < threshold_size[0] and size[1] < threshold_size[1]:

-------------------------------------------------------------------------
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

Reply via email to