image magic: add bmp and tiff + Readme
This commit is contained in:
parent
4cd968daa6
commit
ace772812a
18
README.md
18
README.md
@ -120,6 +120,24 @@ The following packages are optional:
|
|||||||
Python bindings of fontconfig are required for displaying
|
Python bindings of fontconfig are required for displaying
|
||||||
genealogical symbols
|
genealogical symbols
|
||||||
|
|
||||||
|
* **magic**
|
||||||
|
|
||||||
|
Python magic bindings required to have better performances with image
|
||||||
|
processing.
|
||||||
|
If this module is not available, we continue to use Gdk.
|
||||||
|
This avoid to load the image in memory. This is a real improvement
|
||||||
|
when we have many big images.
|
||||||
|
Used in odfdoc, rtfdoc and webreport and tested with png, gif, jpeg, bmp, tiff
|
||||||
|
#
|
||||||
|
# file size with magic without (Gdk) ratio
|
||||||
|
# example 1 : 256k 0.00080 0.00575 7
|
||||||
|
# example 2 : 21M 0.00171 0.55860 326
|
||||||
|
|
||||||
|
Debian, Ubuntu, ... : python3-magic
|
||||||
|
Fedora, Redhat, ... : python3-magic
|
||||||
|
openSUSE : python-magic
|
||||||
|
ArchLinux : python-magic
|
||||||
|
|
||||||
Optional packages required by Third-party Addons
|
Optional packages required by Third-party Addons
|
||||||
------------------------------------------------
|
------------------------------------------------
|
||||||
|
|
||||||
|
@ -168,12 +168,18 @@ def image_size(source):
|
|||||||
# For performance reasons, we'll try to get image size from magic.
|
# For performance reasons, we'll try to get image size from magic.
|
||||||
# This avoid to load the image in memory. This is a real improvement
|
# This avoid to load the image in memory. This is a real improvement
|
||||||
# when we have many big images.
|
# when we have many big images.
|
||||||
# Used in odfdoc, rtfdoc and webreport and tested with png, gif, jpeg
|
# Used in odfdoc, rtfdoc and webreport and tested with png, gif, jpeg,
|
||||||
|
# bmp, tiff
|
||||||
#
|
#
|
||||||
# file size with magic without (Gdk) ratio
|
# file size with magic without (Gdk) ratio
|
||||||
# example 1 : 256k 0.00080 0.00575 7
|
# example 1 : 256k 0.00080 0.00575 7
|
||||||
# example 2 : 21M 0.00171 0.55860 326
|
# example 2 : 21M 0.00171 0.55860 326
|
||||||
img = magic.from_file(source)
|
img = magic.from_file(source)
|
||||||
|
found = img.find("TIFF")
|
||||||
|
if found == 0:
|
||||||
|
width = re.search('width=(\d+)', img).groups()
|
||||||
|
height = re.search('height=(\d+)', img).groups()
|
||||||
|
return (int(width[0]), int(height[0]))
|
||||||
found = img.find("precision")
|
found = img.find("precision")
|
||||||
if found > 0:
|
if found > 0:
|
||||||
img = img[found:]
|
img = img[found:]
|
||||||
|
Loading…
x
Reference in New Issue
Block a user