Hi Duncan,
I could not apply your patch. I get the following error messages.
patching file www/htdocs/library.rpy
Hunk #2 FAILED at 70.
Hunk #3 FAILED at 289.
Hunk #4 FAILED at 313.
Hunk #5 FAILED at 465.
Hunk #6 FAILED at 607.
5 out of 7 hunks FAILED -- saving rejects to file www/htdocs/library.rpy.rej
I am at r8883. Anyway seems like you code does almost the same things
as mine except that in your case if a cached image exists then it is
used without actually making sure if the size if what the user
requested. If we make WWW_IMAGE_THUMBNAIL_SIZE a config then it can
change any time and the code has to make sure it does what the user
want. In my code I make a check and rescale if necessary. Please see
if you can merge my code into you code changes or you can update the
svn with your patch and I will make the change or send me the correct
patch.
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))
Regards
Chandan
On 12/31/06, Duncan Webb <[EMAIL PROTECTED]> wrote:
> Chandan Pitta wrote:
> > Added WWW_IMAGE_SIZE and WWW_IMAGE_THRESHOLD to library.rpy. Did not
> > know if I should add those variable to freevo_config.py or the
> > maintainer will add them.
> >
> > Example usage
> > WWW_IMAGE_SIZE = (100, 100)
> > WWW_IMAGE_THRESHOLD = (800, 600)
> >
> > Regards,
> > Chandan
> >
> >
> > On 12/30/06, Ryan Roth <[EMAIL PROTECTED]> wrote:
> >> WWW_IMAGE_THRESHOLD
> >>
>
> I've already added sizes but as:
> ==============================================================================
> --- branches/rel-1/freevo/freevo_config.py (original)
> +++ branches/rel-1/freevo/freevo_config.py Sun Dec 31 18:04:53 2006
> @@ -1753,6 +1753,12 @@
> WEBSERVER_GID = 0
>
> #
> +# Some sizes for the images in the web library
> +#
> +WWW_IMAGE_THUMBNAIL_SIZE = (200, 200)
> +WWW_IMAGE_THRESHOLD_SIZE = (800, 600)
> +
> +#
> # Username / Password combinations to login to the web interface.
> # These should be overridden in local_conf.py
> #
>
> Also noticed that the last patch didn't show the thumbnails from the
> cache directory. Wish I know what TwistedWeb was doing with them. :( May
> be I've missed something out.
>
> Also discovered a better function call in imlib that scales the images
> correctly, keeping the aspect ratio, just by passing the max size.
>
> Attached is a patch that still doesn't show the thumbnail images
> correctly, but has the two changes above already in.
>
> Attached are some alternative images for folders, based on what we
> already have in freevo.
>
> Duncan
>
>
> Index: src/www/htdocs/library.rpy
> ===================================================================
> --- src/www/htdocs/library.rpy (revision 8883)
> +++ src/www/htdocs/library.rpy (working copy)
> @@ -1,5 +1,4 @@
> #!/usr/bin/python
> -
> # -----------------------------------------------------------------------
> # library.rpy - a script to display and modify your video library
> # -----------------------------------------------------------------------
> @@ -71,13 +70,27 @@
> return FALSE
>
> def convert_dir(self, dir_str):
> + '''
> + Converts a direct file location to a link that twisted can display.
> + If the file exists in one of the child resources of twisted, then
> + this method converts the file to a proper child resource link that
> + twiseted knows about.
> + If above case fails, the original file link will be returned.
> + '''
> print 'convert_dir(self, dir_str=%r)' % (dir_str)
> - for i in range(len(self.allowed_dirs)):
> - val = self.allowed_dirs[i][1]
> - if dir_str.startswith(val):
> - return val.replace("/", "_") + dir_str[len(val):]
> - return dir_str
> + child_res = ""
> + ### if the file starts with FREEVO_CACHEDIR return converted file
> + if dir_str.startswith(config.FREEVO_CACHEDIR):
> + child_res = config.FREEVO_CACHEDIR
> + else:
> + for i in range(len(self.allowed_dirs)):
> + val = self.allowed_dirs[i][1]
> + if dir_str.startswith(val):
> + child_res = val
> + break
>
> + return child_res.replace("/", "_") + dir_str[len(child_res):]
> +
> def get_suffixes (self, media):
> print 'get_suffixes (self, media=\"%s\")' % (media)
> suffixes = []
> @@ -276,7 +289,7 @@
> fv.printLinks()
> fv.printFooter()
>
> - elif action_mediatype and len(action_dir) == 0:
> + elif action_mediatype and action_dir and len(action_dir) == 0:
> # show the appropriate dirs from config variables
> # make a back to pick music or movies
> # now make the list unique
> @@ -300,7 +313,7 @@
> fv.printLinks()
> fv.printFooter()
>
> - elif action_mediatype and len(action_dir) and action != "download":
> + elif action_mediatype and action_dir and len(action_dir) and action
> != "download":
> if not self.check_dir(action_mediatype,action_dir) and action !=
> 'view':
> # why
> sys.exit(1)
> @@ -452,11 +465,12 @@
> status = 'favorite'
> ### show image
> if action_mediatype == "images":
> + size = (info['width'], info['height'])
> + (scaled_image, new_size) =
> self.get_scaled_image_and_size(filepath, size)
> + print 'DJW:new_size:', new_size
> image_link = self.convert_dir(filepath)
> - size = (info['width'], info['height'])
> - new_size = self.resize_image(image_link, size)
> fv.tableCell('<a
> href="javascript:openfoto(\''+image_link+'\','+str(size[0])+','+str(size[1])+')">'\
> - +'<img src="'+image_link+'"
> height="'+str(new_size[1])+'px" width="'+str(new_size[0])+'px" />'\
> + +'<img src="'+scaled_image+'"
> height="'+str(new_size[1])+'px" width="'+str(new_size[0])+'px" />'\
> +'<br />'+Unicode(title)+'</a>',
> 'class="'+status+'" colspan="1"')
> ### show movie
> elif action_mediatype == "movies" or action_mediatype ==
> "rectv":
> @@ -593,23 +607,34 @@
> new_height = 200
> return [int(new_width), int(new_height + 0.5)]
>
> - def resize_image_to_square(self, image, size):
> - print 'resize_image_to_square(self, image=%s, size=%s)' % (image,
> size)
> - ### if aspect ratio > 1 then scale width to 200
> - new_size = [200, 200]
> - try:
> - if size[0] > size[1]:
> - new_size[0] = 200
> - new_size[1] = new_size[0] * size[1] / size[0]
> - ### else scale height to 200
> + 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.
> + '''
> + print 'get_scaled_image(self, filepath=%r, size=%s)' % (filepath,
> size)
> + threshold_size = config.WWW_IMAGE_THRESHOLD_SIZE
> + scaled_image_path = self.cache_dir + filepath.replace("/",
> "_").replace(".", "_") + ".jpg"
> + new_size = size
> + print 'DJW:scaled_image_path=%r' % scaled_image_path
> + if not os.path.exists(scaled_image_path):
> + if size[0] > threshold_size[0] or size[1] > threshold_size[1]:
> + image = imlib2.open(filepath)
> + new_image =
> image.scale_preserve_aspect(config.WWW_IMAGE_THUMBNAIL_SIZE)
> + print 'DJW:new_image:', new_image
> + new_image.save(scaled_image_path)
> + new_size = new_image.size
> else:
> - new_size[1] = 200
> - new_size[0] = new_size[1] * size[0] / size[1]
> - except ZeroDivisionError:
> - pass
> - return new_size
> -
> + scaled_image_path = filepath
> + scaled_image_path = self.convert_dir(scaled_image_path)
> + print 'DJW:scaled_image_path=%r' % scaled_image_path
> + return (scaled_image_path, new_size)
> +
> def get_fxd_title(self, fxd_file):
> + print 'get_fxd_title(self, fxd_file=%r)', (fxd_file)
> fxd_info = ""
> parser = util.fxdparser.FXD(fxd_file)
> parser.parse()
> @@ -620,4 +645,3 @@
>
>
> resource = LibraryResource()
> -
>
> -------------------------------------------------------------------------
> 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