Bonjour à tous, Mon premier message ici dont j'espère qu'il me permettra de trouver un moyen d'avancer. Je cherche à créer un processeur d'image personnalisé en « subclassant » sorl-thumbnail, installé via pip dans mon projet.
Seulement, je n'ai pas le moindre début d'idée d'où écrire ce code. Sur stackOverflow, j'ai trouvé ça : [url]http://stackoverflow.com/questions/6151468/image-filtering-with-the-new-sorl-thumbnail[/url], qui propose une base de code pour étendre sorl-thumbnail. [quote] you can implement custom processing by creating (by subclassing) an engine, setting THUMBNAIL_ENGINE and overriding the create() method. For example, to add a processing option to generate rounded corners: [code] from sorl.thumbnail.engines.pil_engine import Engine class RoundedCornerEngine(Engine): def create(self, image, geometry, options): image = super(RoundedCornerEngine, self).create(image, geometry, options) image = self.cornerize(image, geometry, options) return image def cornerize(self, image, geometry, options): if 'cornerradius' in options: ...whatever... return image [/code] and you'd call that in a template as (note the cornerradius option): [code]{% thumbnail my_image "300x150" format="PNG" cornerradius=10 as thumb %} <img class="thumb" src="{{ thumb.url }}"> {% endthumbnail %} [/code] [/quote] Où dois-je créer ce fichier ? Comment doit-il s'appeler ? Et pour un peu plus tard, si vous avez déjà fait ce genre de choses (manipulation d'image via imageMagick ou PIL), où puis-je trouver quelques exemples pour me guider dans le remplacement de ce « …whatever… » ? Merci d'avance de vos réponses. _______________________________________________ django mailing list [email protected] http://lists.afpy.org/mailman/listinfo/django
