|
@@ -2,17 +2,21 @@ |
|
|
""" |
|
|
""" |
|
|
Contains classes to handle images related things |
|
|
Contains classes to handle images related things |
|
|
|
|
|
|
|
|
# Requires PIL |
|
|
|
|
|
|
|
|
# Requires PIL or pillow |
|
|
""" |
|
|
""" |
|
|
|
|
|
|
|
|
from hyde.plugin import Plugin |
|
|
from hyde.plugin import Plugin |
|
|
from hyde.fs import File, Folder |
|
|
|
|
|
|
|
|
|
|
|
import re |
|
|
import re |
|
|
import Image |
|
|
|
|
|
import glob |
|
|
import glob |
|
|
import os |
|
|
import os |
|
|
|
|
|
|
|
|
|
|
|
try: |
|
|
|
|
|
from PIL import Image |
|
|
|
|
|
except ImportError: |
|
|
|
|
|
# No pillow |
|
|
|
|
|
import Image |
|
|
|
|
|
|
|
|
class ImageSizerPlugin(Plugin): |
|
|
class ImageSizerPlugin(Plugin): |
|
|
""" |
|
|
""" |
|
|
Each HTML page is modified to add width and height for images if |
|
|
Each HTML page is modified to add width and height for images if |
|
@@ -239,7 +243,7 @@ class ImageThumbnailsPlugin(Plugin): |
|
|
path = os.path.join(".thumbnails", |
|
|
path = os.path.join(".thumbnails", |
|
|
os.path.dirname(resource.get_relative_deploy_path()), |
|
|
os.path.dirname(resource.get_relative_deploy_path()), |
|
|
"%s%s" % (prefix, name)) |
|
|
"%s%s" % (prefix, name)) |
|
|
target = File(Folder(resource.site.config.content_root_path).child(path)) |
|
|
|
|
|
|
|
|
target = resource.site.config.content_root_path.child_file(path) |
|
|
res = self.site.content.add_resource(target) |
|
|
res = self.site.content.add_resource(target) |
|
|
res.set_relative_deploy_path(res.get_relative_deploy_path().replace('.thumbnails/', '', 1)) |
|
|
res.set_relative_deploy_path(res.get_relative_deploy_path().replace('.thumbnails/', '', 1)) |
|
|
|
|
|
|
|
|