11<?php
2+ /**
3+ * Copyright (c) 2019 PHP-QuickORM ImageResize
4+ * Author: Rytia Leung
5+ * Email: Rytia@Outlook.com
6+ * Github: github.com/php-quickorm/ImageResize
7+ */
8+
29class ImageResize
310{
411 private $ path ;
@@ -10,6 +17,13 @@ class ImageResize
1017 private $ rawResource ;
1118 private $ newResource ;
1219
20+ /**
21+ * ImageResize constructor.
22+ * @param string $path
23+ * @param int $width
24+ * @param int $height
25+ * @param string $sourceFormat
26+ */
1327 public function __construct ($ path , $ width = 170 , $ height = 128 , $ sourceFormat = null )
1428 {
1529
@@ -31,6 +45,9 @@ public function __construct($path, $width = 170, $height = 128, $sourceFormat =
3145 $ this ->generate ();
3246 }
3347
48+ /**
49+ * Generate image
50+ */
3451 private function generate (){
3552 // Get new sizes
3653 list ($ oldWidth , $ oldHeight ) = getimagesize ($ this ->path );
@@ -63,6 +80,15 @@ private function generate(){
6380
6481 }
6582
83+ /**
84+ * Add water mark to image
85+ * @param string $path
86+ * @param int $width
87+ * @param int $height
88+ * @param string $positionX
89+ * @param string $positionY
90+ * @param int $margin
91+ */
6692 public function addImageMark ($ path , $ width = 50 , $ height = 50 , $ positionX = "right " , $ positionY = "bottom " , $ margin = 10 ){
6793
6894 $ im = (new ImageResize ($ path , $ width , $ height ))->getImageResource ();
@@ -83,6 +109,15 @@ public function addImageMark($path, $width = 50, $height = 50, $positionX = "rig
83109
84110 }
85111
112+ /**
113+ * Add text to image
114+ * @param string $text
115+ * @param int $fontSize
116+ * @param string $color
117+ * @param string $positionX
118+ * @param string $positionY
119+ * @param int $margin
120+ */
86121 public function addTextMark ($ text , $ fontSize = 5 , $ color = "#0000ff " , $ positionX = "right " , $ positionY = "bottom " , $ margin = 10 ){
87122
88123 $ textWidth = imagefontwidth ($ fontSize ) * strlen ($ text );
@@ -105,13 +140,21 @@ public function addTextMark($text, $fontSize = 5, $color = "#0000ff", $positionX
105140 imagestring ( $ this ->newResource , $ fontSize , $ dstX , $ dstY , $ text , $ textColor );
106141 }
107142
143+ /**
144+ * Get PHP GD resource
145+ * @return resource
146+ */
108147 public function getImageResource ()
109148 {
110149 return $ this ->newResource ;
111150 }
112151
113152
114-
153+ /**
154+ * Save the image as file
155+ * @param string $path
156+ * @param null $format
157+ */
115158 public function save ($ path , $ format = null ){
116159
117160 if (is_null ($ format )) {
@@ -137,6 +180,9 @@ public function save($path, $format = null){
137180
138181 }
139182
183+ /**
184+ * Send HTTP Response
185+ */
140186 public function render (){
141187 switch ($ this ->extension ){
142188 case 'jpg ' :
0 commit comments