Skip to content

Commit 6fd820b

Browse files
committed
added imagick functions
1 parent 74b9c3c commit 6fd820b

File tree

4 files changed

+301
-0
lines changed

4 files changed

+301
-0
lines changed

generated/functionsList.php

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -276,6 +276,19 @@
276276
'imagecopymergegray',
277277
'imagecopyresampled',
278278
'imagecopyresized',
279+
'imagecreate',
280+
'imagecreatefrombmp',
281+
'imagecreatefromgd',
282+
'imagecreatefromgd2',
283+
'imagecreatefromgd2part',
284+
'imagecreatefromgif',
285+
'imagecreatefromjpeg',
286+
'imagecreatefrompng',
287+
'imagecreatefromwbmp',
288+
'imagecreatefromwebp',
289+
'imagecreatefromxbm',
290+
'imagecreatefromxpm',
291+
'imagecreatetruecolor',
279292
'imagecrop',
280293
'imagecropauto',
281294
'imagedashedline',

generated/image.php

Lines changed: 271 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -640,6 +640,277 @@ function imagecopyresized($dst_image, $src_image, int $dst_x, int $dst_y, int $s
640640
}
641641

642642

643+
/**
644+
* imagecreate returns an image identifier
645+
* representing a blank image of specified size.
646+
*
647+
* In general, we recommend the use of
648+
* imagecreatetruecolor instead of
649+
* imagecreate so that image processing occurs on the
650+
* highest quality image possible. If you want to output a palette image, then
651+
* imagetruecolortopalette should be called immediately
652+
* before saving the image with imagepng or
653+
* imagegif.
654+
*
655+
* @param int $width The image width.
656+
* @param int $height The image height.
657+
* @return resource Returns an image resource identifier on success, FALSE on errors.
658+
* @throws ImageException
659+
*
660+
*/
661+
function imagecreate(int $width, int $height)
662+
{
663+
error_clear_last();
664+
$result = \imagecreate($width, $height);
665+
if ($result === false) {
666+
throw ImageException::createFromPhpError();
667+
}
668+
return $result;
669+
}
670+
671+
672+
/**
673+
* imagecreatefrombmp returns an image identifier
674+
* representing the image obtained from the given filename.
675+
*
676+
* @param string $filename Path to the BMP image.
677+
* @return resource Returns an image resource identifier on success, FALSE on errors.
678+
* @throws ImageException
679+
*
680+
*/
681+
function imagecreatefrombmp(string $filename)
682+
{
683+
error_clear_last();
684+
$result = \imagecreatefrombmp($filename);
685+
if ($result === false) {
686+
throw ImageException::createFromPhpError();
687+
}
688+
return $result;
689+
}
690+
691+
692+
/**
693+
* Create a new image from GD file or URL.
694+
*
695+
* @param string $filename Path to the GD file.
696+
* @return resource Returns an image resource identifier on success, FALSE on errors.
697+
* @throws ImageException
698+
*
699+
*/
700+
function imagecreatefromgd(string $filename)
701+
{
702+
error_clear_last();
703+
$result = \imagecreatefromgd($filename);
704+
if ($result === false) {
705+
throw ImageException::createFromPhpError();
706+
}
707+
return $result;
708+
}
709+
710+
711+
/**
712+
* Create a new image from GD2 file or URL.
713+
*
714+
* @param string $filename Path to the GD2 image.
715+
* @return resource Returns an image resource identifier on success, FALSE on errors.
716+
* @throws ImageException
717+
*
718+
*/
719+
function imagecreatefromgd2(string $filename)
720+
{
721+
error_clear_last();
722+
$result = \imagecreatefromgd2($filename);
723+
if ($result === false) {
724+
throw ImageException::createFromPhpError();
725+
}
726+
return $result;
727+
}
728+
729+
730+
/**
731+
* Create a new image from a given part of GD2 file or URL.
732+
*
733+
* @param string $filename Path to the GD2 image.
734+
* @param int $srcX x-coordinate of source point.
735+
* @param int $srcY y-coordinate of source point.
736+
* @param int $width Source width.
737+
* @param int $height Source height.
738+
* @return resource Returns an image resource identifier on success, FALSE on errors.
739+
* @throws ImageException
740+
*
741+
*/
742+
function imagecreatefromgd2part(string $filename, int $srcX, int $srcY, int $width, int $height)
743+
{
744+
error_clear_last();
745+
$result = \imagecreatefromgd2part($filename, $srcX, $srcY, $width, $height);
746+
if ($result === false) {
747+
throw ImageException::createFromPhpError();
748+
}
749+
return $result;
750+
}
751+
752+
753+
/**
754+
* imagecreatefromgif returns an image identifier
755+
* representing the image obtained from the given filename.
756+
*
757+
* @param string $filename Path to the GIF image.
758+
* @return resource Returns an image resource identifier on success, FALSE on errors.
759+
* @throws ImageException
760+
*
761+
*/
762+
function imagecreatefromgif(string $filename)
763+
{
764+
error_clear_last();
765+
$result = \imagecreatefromgif($filename);
766+
if ($result === false) {
767+
throw ImageException::createFromPhpError();
768+
}
769+
return $result;
770+
}
771+
772+
773+
/**
774+
* imagecreatefromjpeg returns an image identifier
775+
* representing the image obtained from the given filename.
776+
*
777+
* @param string $filename Path to the JPEG image.
778+
* @return resource Returns an image resource identifier on success, FALSE on errors.
779+
* @throws ImageException
780+
*
781+
*/
782+
function imagecreatefromjpeg(string $filename)
783+
{
784+
error_clear_last();
785+
$result = \imagecreatefromjpeg($filename);
786+
if ($result === false) {
787+
throw ImageException::createFromPhpError();
788+
}
789+
return $result;
790+
}
791+
792+
793+
/**
794+
* imagecreatefrompng returns an image identifier
795+
* representing the image obtained from the given filename.
796+
*
797+
* @param string $filename Path to the PNG image.
798+
* @return resource Returns an image resource identifier on success, FALSE on errors.
799+
* @throws ImageException
800+
*
801+
*/
802+
function imagecreatefrompng(string $filename)
803+
{
804+
error_clear_last();
805+
$result = \imagecreatefrompng($filename);
806+
if ($result === false) {
807+
throw ImageException::createFromPhpError();
808+
}
809+
return $result;
810+
}
811+
812+
813+
/**
814+
* imagecreatefromwbmp returns an image identifier
815+
* representing the image obtained from the given filename.
816+
*
817+
* @param string $filename Path to the WBMP image.
818+
* @return resource Returns an image resource identifier on success, FALSE on errors.
819+
* @throws ImageException
820+
*
821+
*/
822+
function imagecreatefromwbmp(string $filename)
823+
{
824+
error_clear_last();
825+
$result = \imagecreatefromwbmp($filename);
826+
if ($result === false) {
827+
throw ImageException::createFromPhpError();
828+
}
829+
return $result;
830+
}
831+
832+
833+
/**
834+
* imagecreatefromwebp returns an image identifier
835+
* representing the image obtained from the given filename.
836+
*
837+
* @param string $filename Path to the WebP image.
838+
* @return resource Returns an image resource identifier on success, FALSE on errors.
839+
* @throws ImageException
840+
*
841+
*/
842+
function imagecreatefromwebp(string $filename)
843+
{
844+
error_clear_last();
845+
$result = \imagecreatefromwebp($filename);
846+
if ($result === false) {
847+
throw ImageException::createFromPhpError();
848+
}
849+
return $result;
850+
}
851+
852+
853+
/**
854+
* imagecreatefromxbm returns an image identifier
855+
* representing the image obtained from the given filename.
856+
*
857+
* @param string $filename Path to the XBM image.
858+
* @return resource Returns an image resource identifier on success, FALSE on errors.
859+
* @throws ImageException
860+
*
861+
*/
862+
function imagecreatefromxbm(string $filename)
863+
{
864+
error_clear_last();
865+
$result = \imagecreatefromxbm($filename);
866+
if ($result === false) {
867+
throw ImageException::createFromPhpError();
868+
}
869+
return $result;
870+
}
871+
872+
873+
/**
874+
* imagecreatefromxpm returns an image identifier
875+
* representing the image obtained from the given filename.
876+
*
877+
* @param string $filename Path to the XPM image.
878+
* @return resource Returns an image resource identifier on success, FALSE on errors.
879+
* @throws ImageException
880+
*
881+
*/
882+
function imagecreatefromxpm(string $filename)
883+
{
884+
error_clear_last();
885+
$result = \imagecreatefromxpm($filename);
886+
if ($result === false) {
887+
throw ImageException::createFromPhpError();
888+
}
889+
return $result;
890+
}
891+
892+
893+
/**
894+
* imagecreatetruecolor returns an image identifier
895+
* representing a black image of the specified size.
896+
*
897+
* @param int $width Image width.
898+
* @param int $height Image height.
899+
* @return resource Returns an image resource identifier on success, FALSE on errors.
900+
* @throws ImageException
901+
*
902+
*/
903+
function imagecreatetruecolor(int $width, int $height)
904+
{
905+
error_clear_last();
906+
$result = \imagecreatetruecolor($width, $height);
907+
if ($result === false) {
908+
throw ImageException::createFromPhpError();
909+
}
910+
return $result;
911+
}
912+
913+
643914
/**
644915
* Crops an image to the given rectangular area and returns the resulting image.
645916
* The given image is not modified.

generator/src/DocPage.php

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -103,6 +103,10 @@ public function detectFalsyFunction(): bool
103103
return true;
104104
}
105105

106+
if (preg_match('/&gd\.return\.identifier;/m', $file)) {
107+
return true;
108+
}
109+
106110
return false;
107111
}
108112

rector-migrate.yml

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -279,6 +279,19 @@ services:
279279
imagecopymergegray: 'Safe\imagecopymergegray'
280280
imagecopyresampled: 'Safe\imagecopyresampled'
281281
imagecopyresized: 'Safe\imagecopyresized'
282+
imagecreate: 'Safe\imagecreate'
283+
imagecreatefrombmp: 'Safe\imagecreatefrombmp'
284+
imagecreatefromgd: 'Safe\imagecreatefromgd'
285+
imagecreatefromgd2: 'Safe\imagecreatefromgd2'
286+
imagecreatefromgd2part: 'Safe\imagecreatefromgd2part'
287+
imagecreatefromgif: 'Safe\imagecreatefromgif'
288+
imagecreatefromjpeg: 'Safe\imagecreatefromjpeg'
289+
imagecreatefrompng: 'Safe\imagecreatefrompng'
290+
imagecreatefromwbmp: 'Safe\imagecreatefromwbmp'
291+
imagecreatefromwebp: 'Safe\imagecreatefromwebp'
292+
imagecreatefromxbm: 'Safe\imagecreatefromxbm'
293+
imagecreatefromxpm: 'Safe\imagecreatefromxpm'
294+
imagecreatetruecolor: 'Safe\imagecreatetruecolor'
282295
imagecrop: 'Safe\imagecrop'
283296
imagecropauto: 'Safe\imagecropauto'
284297
imagedashedline: 'Safe\imagedashedline'

0 commit comments

Comments
 (0)