Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- class PracaZObrazkami {
- var $image;
- var $image_type;
- function Nacitaj($filename) {
- $image_info = getimagesize($filename);
- $this->image_type = $image_info[2];
- if( $this->image_type == IMAGETYPE_JPEG ) {
- $this->image = imagecreatefromjpeg($filename);
- } elseif( $this->image_type == IMAGETYPE_GIF ) {
- $this->image = imagecreatefromgif($filename);
- } elseif( $this->image_type == IMAGETYPE_PNG ) {
- $this->image = imagecreatefrompng($filename);
- }
- }
- function Uloz($filename, $image_type=IMAGETYPE_JPEG, $compression=75, $permissions=null) {
- if( $image_type == IMAGETYPE_JPEG ) {
- imagejpeg($this->image,$filename,$compression);
- } elseif( $image_type == IMAGETYPE_GIF ) {
- imagegif($this->image,$filename);
- } elseif( $image_type == IMAGETYPE_PNG ) {
- imagepng($this->image,$filename);
- }
- if( $permissions != null) {
- chmod($filename,$permissions);
- }
- }
- function ZistiWidth() {
- return imagesx($this->image);
- }
- function ZistiHeight() {
- return imagesy($this->image);
- }
- function ZmenVelkostHeight($height) {
- $ratio = $height / $this->ZistiHeight();
- $width = $this->ZistiWidth() * $ratio;
- $this->resize($width,$height);
- }
- function ZmenVelkostWidth($width) {
- $ratio = $width / $this->ZistiWidth();
- $height = $this->ZistiHeight() * $ratio;
- $this->ZmenitVelkost($width,$height);
- }
- function ZmenitVelkostPercentualne($scale) {
- $width = $this->ZistiWidth() * $scale/100;
- $height = $this->ZistiHeight() * $scale/100;
- $this->ZmenitVelkost($width,$height);
- }
- function ZmenitVelkost($width,$height) {
- $new_image = imagecreatetruecolor($width, $height);
- imagecopyresampled($new_image, $this->image, 0, 0, 0, 0, $width, $height, $this->ZistiWidth(), $this->ZistiHeight());
- $this->image = $new_image;
- }
- }
- ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement