{"flag":true,"single":true,"pageTitle":"GD library |check image width, height,type ||PHP","post":{"id":332,"user_id":"1","slug":"gd-library-check-image-width-height-type-php-h4np","title":"GD library |check image width, height,type ||PHP","body":"<h1><span style=\"color: #2dc26b;\"><strong>1.Attributes in list<\/strong><\/span><\/h1>\r\n<p><strong>test.php&nbsp;<\/strong><\/p>\r\n<pre class=\"language-markup\"><code>&lt;?php\r\nlist($width, $height, $type, $attr) = getimagesize(\"1.png\");\/\/open as file\r\necho $width.\" \".$height.\" \".$type.\" \".$attr;\r\n?&gt;<\/code><\/pre>\r\n<p><strong>Output<\/strong><\/p>\r\n<pre class=\"language-markup\"><code>1365 603 3 width=\"1365\" height=\"603\"<\/code><\/pre>\r\n<h1><span style=\"color: #2dc26b;\">OR<\/span><\/h1>\r\n<p><strong>code.php<\/strong><\/p>\r\n<pre class=\"language-markup\"><code>$size_info1 = getimagesize($img);\r\nprint_r($size_info1);echo \"&lt;br\/&gt;\";<\/code><\/pre>\r\n<p><strong>Output<\/strong><\/p>\r\n<pre class=\"language-markup\"><code>Array ( [0] =&gt; 200 [1] =&gt; 200 [2] =&gt; 3 [3] =&gt; width=\"200\" height=\"200\" [bits] =&gt; 8 [mime] =&gt; image\/png )<\/code><\/pre>\r\n<h1><span style=\"color: #2dc26b;\">OR open as string<\/span><\/h1>\r\n<p><strong>Code.php<\/strong><\/p>\r\n<pre class=\"language-markup\"><code>$data       = file_get_contents($img);\r\nprint_r($data);echo \"&lt;br\/&gt;\";<\/code><\/pre>\r\n<p><strong>Output: output string of image<\/strong><\/p>\r\n<pre class=\"language-markup\"><code>?PNG  IHDR???X?? pHYs??9iCCPPhotoshop ICC profilex???J?P??E&scaron;V??p'QPl???I[?\r\n......<\/code><\/pre>\r\n<h1><span style=\"color: #2dc26b;\">OR get data from string<\/span><\/h1>\r\n<p><span style=\"color: #000000;\"><strong>code.php<\/strong><\/span><\/p>\r\n<pre class=\"language-markup\"><code>$img = 'stamp.png';\r\n$data       = file_get_contents($img);\r\n$size_info2 = getimagesizefromstring($data);\r\nprint_r($size_info2);echo \"&lt;br\/&gt;\";\r\n<\/code><\/pre>\r\n<p><strong>Output<\/strong><\/p>\r\n<pre class=\"language-markup\"><code>Array ( [0] =&gt; 200 [1] =&gt; 200 [2] =&gt; 3 [3] =&gt; width=\"200\" height=\"200\" [bits] =&gt; 8 [mime] =&gt; image\/png )<\/code><\/pre>\r\n<h1><span style=\"color: #2dc26b;\">&nbsp;OR Width &amp; Height<\/span><\/h1>\r\n<pre class=\"language-markup\"><code>$img = imagecreatefrompng('stamp.png');\r\necho imagesx($img);\t\/\/size of image x axis\r\necho imagesy($img);\t\/\/size of image x axis<\/code><\/pre>\r\n<p>200 200<\/p>\r\n<p>&nbsp;<\/p>","category_id":"1","is_private":"0","created_at":"2026-01-07T11:30:19.000000Z","updated_at":"2026-01-07T11:30:19.000000Z","category":{"id":1,"user_id":"1","name":"PHP","slug":"php-3ius","parent_id":null,"created_at":"2023-03-14T03:58:19.000000Z","updated_at":"2023-03-14T03:58:19.000000Z"},"user":{"id":1,"name":"R GONDAL","email":"rizikmw@gmail.com","email_verified_at":null,"two_factor_confirmed_at":null,"current_team_id":"1","profile_photo_path":null,"created_at":"2023-03-12T10:49:33.000000Z","updated_at":"2025-01-10T12:59:00.000000Z","profile_photo_url":"https:\/\/ui-avatars.com\/api\/?name=R+G&color=7F9CF5&background=EBF4FF"}},"pageDesc":"1.Attributes in list test.php&nbsp; &lt;?php list($width, $height, $type, $attr) = getimagesize(\"1.png\");\/\/open as file echo $width.\" \".$hei - GD library |check image width, height,type ||PHP (Updated: January 7, 2026) - Read more about GD library |check image width, height,type ||PHP at my programming site [SITE]","categories":[]}