Thank you @gferreira! This is a nice example
Also a great motivation to spent a bit more time on writing well structured code. My scripts tend to get messy very quickly.
imik
@imik
Best posts made by imik
Latest posts made by imik
-
RE: Boustrophedonic typesetting
-
RE: newDrawing() size?
You need to specify the size of the new canvas after each
newDrawing()
for i in range(10): newDrawing() size("A4") fill(random()) rect(0, 0, width(), height()) saveImage(f'~/Desktop/file-{i}.pdf') endDrawing()
-
RE: Context leak detected — some help?
Hi @frederik,
I am running macOS version 10.14.6 and the simplified script works perfectly fine on my machine as well.
As I was trying to extend it I got the same output again and I did some trial and error.What am I trying to achieve?
I have in mind a setup where I draw an ImageObject. The ImageObject then can contain text or graphics as well as another image. I then feed it into some arbitrary function to manipulate it.
The clue is that I want to manipulate the manipulated image again. So I am currently returning a new ImageObeject from the manipulation function.I came up with something like this:
w = h = 300 # higher Numbers here result in the context leak numManipulations = 20 def manipulateImage(img, r, angle, pos): tempImg = ImageObject() x, y = pos with tempImg: size(w, h) # Draw the old Image image(img, (0, 0)) fill(None) stroke(0) # Draw the manipulation on top oval(x - r, y - r, r * 2, r * 2) clipPath() rotate(angle, center = (x, y)) image(img, (0, 0)) return(tempImg) im = ImageObject() with im: size(w, h) fill(1) rect(0, 0, w, h) fill(0) fontSize(100) text("Heee", (10, 10)) for a in range(numManipulations): r = randint(20, 40) x = randint(r, w-r) y = randint(r, h-r) angle = randint(0, 360) im = manipulateImage(im, r, angle, (x, y)) newPage(w, h) image(im, (0, 0)) saveImage(f"~/Desktop/test/RotatingImage-{a}.png")
What I found out so far:
-
The scripts runs fine when you only save the final image.
Nope, running 100 repetitions results in the sameContext leak
-
When I am trying to save every step for animation purpose or so I will get
Context leak deteced, msgtracer -1
. No matter usinggif
,mp4
orpng
for later stitching.
Withpng
it usually starts at around 12 repetitions,mp4
orgif
can go up to 100 repetitions, but I guess it depends on the resolution and other factors. -
Running the script within the app you see no problem except on a lot of repetitions the app freezes at some point and you need to kill it. Running the same script then in Terminal you see the
Context leak deteced, msgtracer -1
.
Maybe it is not the best setup for what I have in mind, but I hope one can understand what's happening.
Any input for improvment is much appreciated as well. -
-
Context leak detected — some help?
Hi,
I am currently working on a rather simple script what should end in an animation export. To boost things up I am running the final script in the Terminal, but right now I am stuck with an error:Context Leak detected, msgtracer returned -1
which gives me some insight why DrawBot kept crushing on this script.For the setup:
I want to generate an ImageObject() which will
then be rotated, for that I wrote my own functiondef drawRotatedImage(img, angle, pos): x, y = pos oval(x - r, y - r, r * 2, r * 2) clipPath() rotate(angle, center = (x, y)) image(img, (0, 0))
I setup my own ImageObject
im = ImageObject() with im: size("A3") # Drawing
And then call the animation setup as follows:
for frame in range(numFrames): newPage("A3") drawRotatedImage(im, angle, pos) # call the function bunch of times
I narrowed it down that the problem lies somewhere within
drawRotatedImage()
and I think it has something to do with drawing the image object within this function. But at the moment I am lost on how I could fix this problem.Any help and explanation on this problem will be much appreciated!
-
RE: Saving Image with different ColorProfile
Hey @frederik
Thank you very much for your reply.
I did some quick tests with the code you provided but it seems I have not achieved any positive result in saving the pages with the provided color profile data.
The results were always GenericRGB for TIFF, JPG and PNG regardless of me also using some other ICC files.dataWithContentsOfFile_
returns an objective-c class NSConcreteData with the data represented as b'…' in it, what I guess is right and whatimageColorSyncProfileData
needs.Anyway, thanks again for your help.
-
RE: Saving Image with different ColorProfile
Hey @gferreira,
thank you for you reply! I will have a more detailed look into the PIL-Library but I think that's it for the moment.
Still, if you have some further information or any idea where to find something about theimageColorSyncProfileData
and how to use it that would be great! Always happy to learn something new.Have a great day.
-
Saving Image with different ColorProfile
Hello,
I am stuck with a problem where I try to open an image inImageObject()
apply a.dotScreen
filter on it and save it again.
Now I always end up with an image saved with RGB profile but I would like to generate an image just black and white — no color information.
I looked into the documentation and first I thought it has something to do withcolorSpace()
but I guess that is not the case.
So I ended up by the saving options and I think thatimageColorSyncProfileData
is actually what I am looking for. But I do not understand how to work with it.For further interest I would be keen to know if there is a way to convert images into different profiles. Especially thinking about print production where I maybe need certain ICC-Profiles.
I am happy for any help or information for a solution.
Thank you.