Wie kann ich in Python Zauberstab den Convex_hull () eines Bildes nur dann nehmen, wenn es einen transparenten HintergruPython

Python-Programme
Anonymous
 Wie kann ich in Python Zauberstab den Convex_hull () eines Bildes nur dann nehmen, wenn es einen transparenten Hintergru

Post by Anonymous »

I am trying to pack images. Für PNGs kann ein transparenter Hintergrund vernachlässigt werden - ich kann die Grenze des Bildes als Polygon nehmen, das aus der Ausgabe eines Aufrufs auf Zauberstab definiert ist. wand.image.convex_hull() should be a rectangle.

Code: Select all

wand.image.convex_hull()
accepts an optional argument called background which defines which colour should be evaluated as the background. This should be a wand.color.Color object, which can in turn be defined by hex code, rgb, hsl, or by ImageMagick colour name. ImageMagick includes a colour called none which is "shorthand for rgba(0, 0, 0, 0.0)."
However, if I call wand.image.convex_hull(background=wand.color.Color("none")), the output is the same as if I don't specify a background colour. Dieses Verhalten scheint falsch zu sein, da es stattdessen eine Reihe von Punkten zurückgeben sollte, die ein Rechteck bilden, wenn das Bild einen nicht transparenten Hintergrund hat. < /P>
Was mache ich hier falsch?

Code: Select all

with image.Image(filename=file) as img:
points = img.convex_hull(background=Color("transparent"))

Quick Reply

Change Text Case: 
   
  • Similar Topics
    Replies
    Views
    Last post