← Back to team overview

openlp-core team mailing list archive

Re: [Merge] lp:~knightrider0xd/openlp/preview-shows-live-fix-1080596 into lp:openlp

 

Review: Needs Information

Just one clarification?

Diff comments:

> === modified file 'openlp/core/lib/__init__.py'
> --- openlp/core/lib/__init__.py	2016-04-17 19:32:15 +0000
> +++ openlp/core/lib/__init__.py	2016-05-06 02:05:04 +0000
> @@ -174,10 +178,24 @@
>      ext = os.path.splitext(thumb_path)[1].lower()
>      reader = QtGui.QImageReader(image_path)
>      if size is None:
> +        # No size given; use default height of 88
>          ratio = reader.size().width() / reader.size().height()
>          reader.setScaledSize(QtCore.QSize(int(ratio * 88), 88))
> -    else:
> +    elif size.isValid():
> +        # Complete size given
>          reader.setScaledSize(size)
> +    else:
> +        # Invalid size given
> +        ratio = reader.size().width() / reader.size().height()

What happens if the height is 0? DivideByZero exception?

> +        if size.width() >= 0:
> +            # Valid width; scale height
> +            reader.setScaledSize(QtCore.QSize(size.width(), int(size.width() / ratio)))
> +        elif size.height() >= 0:
> +            # Valid height; scale width
> +            reader.setScaledSize(QtCore.QSize(int(ratio * size.height()), size.height()))
> +        else:
> +            # Invalid; use default height of 88
> +            reader.setScaledSize(QtCore.QSize(int(ratio * 88), 88))
>      thumb = reader.read()
>      thumb.save(thumb_path, ext[1:])
>      if not return_icon:


-- 
https://code.launchpad.net/~knightrider0xd/openlp/preview-shows-live-fix-1080596/+merge/293962
Your team OpenLP Core is subscribed to branch lp:openlp.


References