-
- include('SimpleImage.php');
- $image = new SimpleImage();
- $image->load('picture.jpg');
- $image->resize (250,400);
- $image->save('picture2.jpg');?>
-
Copy the code
2, set the width, and scale proportionally
-
- include('SimpleImage.php');
- $image = new SimpleImage();
- $image->load('picture.jpg');
- $image-> resizeToWidth(250);
- $image->save('picture2.jpg');?>
-
Copy code
3, set height, scale proportionally
-
- include('SimpleImage.php');
- $image = new SimpleImage();
- $image->load('picture.jpg');
- $image-> resizeToHeight(500);
- $image->save('picture2.jpg');
- $image->resizeToHeight(200);
- $image->save('picture3.jpg');?>
-
Copy the code
4, scale it to 50%
-
- include('SimpleImage.php');
- $image = new SimpleImage();
- $image->load('picture.jpg');
- $image-> scale(50);
- $image->save('picture2.jpg');?>
-
Copy the code
5, and output it directly to the screen after scaling
-
- header('Content-Type: image/jpeg');
- include('SimpleImage.php');
- $image = new SimpleImage();
- $image->load ('picture.jpg');
- $image->resizeToWidth(150);
- $image->output();?>
Copy code
Instructions:
SimpleImage.php
Get it from the download link provided at the beginning of this article.
>>>> Articles you may be interested in:
Example reference for php proportional scaling of images
PHP tool for scaling images in equal proportions SimpleImage example learning
php code example for batch zooming images
|