@@ -191,6 +191,11 @@ sub gdImageFilledEllipse (gdImagePtr $im, int32 $cx, int32 $cy, int32 $w, int32
191191 # returns void
192192 is native(LIB) is export {* }
193193
194+ sub gdImageEllipse (gdImagePtr $ im , int32 $ cx , int32 $ cy , int32 $ w , int32 $ h ,
195+ int32 $ color )
196+ # returns void
197+ is native(LIB) is export {* }
198+
194199sub gdImageCopyResized (gdImageStruct $ dst , gdImageStruct $ src ,
195200 int32 $ dstX , int32 $ dstY ,
196201 int32 $ srcX , int32 $ srcY ,
@@ -301,6 +306,10 @@ sub gdImageFilledRectangle(gdImagePtr $im, int32 $x1, int32 $y1, int32 $x2, int3
301306 # returns void
302307 is native(LIB) is export {* }
303308
309+ sub gdImageRectangle (gdImagePtr $ im , int32 $ x1 , int32 $ y1 , int32 $ x2 , int32 $ y2 , int32 $ color )
310+ # returns void
311+ is native(LIB) is export {* }
312+
304313class gdPoint is repr(' CStruct' ) is export {
305314 has int32 $ . x is rw = 0 ;
306315 has int32 $ . y is rw = 0 ;
@@ -541,6 +550,64 @@ origin as possible.
541550LibGD is large and this module far from covers it all. Feel free to add anything
542551your missing and submit a pull request!
543552
553+ = head1 MEMORY MANAGEMENT
554+
555+ When creating an in-memory image, some memory is allocated in GD. This
556+ memory is not automatically deallocated when the variable which refers
557+ to the image goes out of scope. To counter this possible memory leak,
558+ the simplest way is to use the C < LEAVE > phaser and call function
559+ C < gdImageDestroy > like this
560+
561+ = begin code :lang<raku>
562+
563+ my $img = gdImageCreateFromPng($fh);
564+ LEAVE gdImageDestroy($_) with $img;
565+
566+ = end code
567+
568+ If a program creates several images, there will be a problem if the
569+ program reuses the C < $img > variable. In this case, you cannot use the
570+ C < LEAVE > phaser, you must call C < gdImageDestroy > before creating the
571+ second image (and the third, and...)
572+
573+ = begin code :lang<raku>
574+
575+ my $img = gdImageCreateFromPng($fh1);
576+ [...]
577+ gdImageDestroy($img);
578+ $img = gdImageCreateFromPng($fh2);
579+ [...]
580+ gdImageDestroy($img);
581+ $img = gdImageCreateFromPng($fh3);
582+ [...]
583+ gdImageDestroy($img);
584+
585+ = end code
586+
587+ Or a simpler solution is to use different variables C < $img1 > ,
588+ C < $img2 > , C < $img3 > and so on, and calling C < gdImageDestroy > each time
589+ with the C < LEAVE > phaser.
590+
591+ = begin code :lang<raku>
592+
593+ my $img1 = gdImageCreateFromPng($fh1);
594+ LEAVE gdImageDestroy($_) with $img1;
595+ [...]
596+ my $img2 = gdImageCreateFromPng($fh2);
597+ LEAVE gdImageDestroy($_) with $img2;
598+ [...]
599+ my $img3 = gdImageCreateFromPng($fh3);
600+ LEAVE gdImageDestroy($_) with $img3;
601+ [...]
602+
603+ = end code
604+
605+ = head1 SEE ALSO
606+
607+ Raku Module C < GD > : L < https://github.com/raku-community-modules/GD >
608+
609+ C library: L < https://libgd.github.io/ >
610+
544611= head1 AUTHORS
545612
546613= item Dagur Valberg Johannsson
@@ -550,7 +617,7 @@ your missing and submit a pull request!
550617
551618Copyright 2013 - 2018 Dagur Valberg Johannsson
552619
553- Copyright 2024 Raku Community
620+ Copyright 2024, 2026 Raku Community
554621
555622This library is free software; you can redistribute it and/or modify it under the Artistic License 2.0.
556623
0 commit comments