miqoo1996/imagemiq

An image upload package which provides lot of functions such as upload, resize, crop, rotate, delete.

1.0.0 2020-04-22 20:16 UTC

This package is auto-updated.

Last update: 2024-05-12 03:52:12 UTC


README

The package helps to work with images easier, provides many functions such as image uploading, resizing, cropping, rotating, deleting.

How to use

  1. composer require miqoo1996/imagemiq
  2. HTML code
<form action="" method="post" enctype="multipart/form-data">
    Select image to upload:
    <input type="file" name="fileToUpload" id="fileToUpload">
    <input type="submit" value="Upload Image" name="submit">
</form>
  1. PHP code
$obj = new \miqoo1996\imagemiq\image();

/**
 * Image types must be one of these.
 *
 * IMAGETYPE_PNG, IMAGETYPE_GIF, IMAGETYPE_JPEG
 * Ex. you can use IMAGETYPE_PNG to convert the image from current format to PNG.
 */
$obj->load($_FILES['fileToUpload']['tmp_name'])
    ->resizeToWidth(500)
    ->save('destination/aaa.png', IMAGETYPE_PNG);


// Some additional methods may come in handy, follow the below examples.


$obj->load($_FILES['fileToUpload']['tmp_name']); // Or $obj->load('image/from/path.jpg');
$obj->scale(2); // new image resized by scaling
$obj->resize(10, 20) // resize the image by the specific width and height
$with = $obj->getWidth();
$height = $obj->getHeight();

Enjoy coding with the nice package!