resized opslaan
Ik heb een probleem ik ben bezig met een resizer maar wat deze moet doen is de resized image opslaan in een map. Het resizen lukt me maar heb geen idee hoe ik het voor elkaar krijg dat de resized_image wordt opgeslagen.
Code (php)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
<?php
// get image
$image = @imagecreatefromjpeg('flower.jpg');
if ($image === false) {
die ('Unable to open image');
}
// Get original width and height
$width = imagesx($image);
$height = imagesy($image);
// New width and height
$new_height = 100;
$new_width = 100;
// Resample
$image_resized = imagecreatetruecolor($new_width, $new_height);
imagecopyresampled($image_resized, $image, 0, 0, 0, 0, $new_width, $new_height, $width, $height);
// Display resized image
header('Content-type: image/jpeg');
imagejpeg($image_resized);
//save resized image
die();
?>
// get image
$image = @imagecreatefromjpeg('flower.jpg');
if ($image === false) {
die ('Unable to open image');
}
// Get original width and height
$width = imagesx($image);
$height = imagesy($image);
// New width and height
$new_height = 100;
$new_width = 100;
// Resample
$image_resized = imagecreatetruecolor($new_width, $new_height);
imagecopyresampled($image_resized, $image, 0, 0, 0, 0, $new_width, $new_height, $width, $height);
// Display resized image
header('Content-type: image/jpeg');
imagejpeg($image_resized);
//save resized image
die();
?>
Perfect werkt uitstekend .. hartelijk dank :D:D:D:D
Code (php)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
<?php
class uploadfoto
{
var $uploadfoto;
var $naam;
var $tmpnaam;
var $size;
var $target;
var $type;
var $allowedfile;
function uploadfoto($uploadfoto)
{
$this->naam = $uploadfoto["name"];
$this->tmpnaam = $uploadfoto["tmp_name"];
$this->size = $uploadfoto["size"];
$this->type = $uploadfoto["type"];
$this->error = $uploadfoto["error"];
$this->target = "C:/server/web/test/foto/";
$this->allowedfile = array('image/pjpeg', 'image/jpeg');
}
function uploadecho()
{
echo "Upload: " . $this->naam . "<br />";
echo "Type: " . $this->type . "<br />";
echo "Size: " . ($this->size / 1024) . " Kb<br />";
echo "Stored in: " . $this->tmpnaam;
echo "<br>";
}
function movefoto($uploadfoto)
{
if(file_exists($this->target.$this->naam)){
echo "Hernoem uw bestand aub";
exit();
}
if(in_array($this->type,$this->allowedfile)){
// get image
$image = @imagecreatefromjpeg($this->tmpnaam);
// Get original width and height
$width = imagesx($image);
$height = imagesy($image);
// New width and height
$new_height = 400;
$new_width = $width * ($new_height/$height);
// Resample
$image_resized = imagecreatetruecolor($new_width, $new_height);
imagecopyresampled($image_resized, $image, 0, 0, 0, 0, $new_width, $new_height, $width, $height);
if ($width > 600)
{
$percent = 0.55;
$new_width = $width * $percent;
$new_height = $height * $percent;
// Resample
$image_resized = imagecreatetruecolor($new_width, $new_height);
imagecopyresampled($image_resized, $image, 0, 0, 0, 0, $new_width, $new_height, $width, $height);
}
//save resized image to file
imagejpeg($image_resized, $this->target . $this->naam);
echo "U heeft uw bestand geupload";
}
else{
echo 'U kunt alleen Jpeg bestanden uploaden';
}
echo "<br>";
}
function showimage()
{
// Send header
header ('Content-Type: image/jpeg');
// Display image
imagejpeg($this->target . $this->naam);
}
}
?>
class uploadfoto
{
var $uploadfoto;
var $naam;
var $tmpnaam;
var $size;
var $target;
var $type;
var $allowedfile;
function uploadfoto($uploadfoto)
{
$this->naam = $uploadfoto["name"];
$this->tmpnaam = $uploadfoto["tmp_name"];
$this->size = $uploadfoto["size"];
$this->type = $uploadfoto["type"];
$this->error = $uploadfoto["error"];
$this->target = "C:/server/web/test/foto/";
$this->allowedfile = array('image/pjpeg', 'image/jpeg');
}
function uploadecho()
{
echo "Upload: " . $this->naam . "<br />";
echo "Type: " . $this->type . "<br />";
echo "Size: " . ($this->size / 1024) . " Kb<br />";
echo "Stored in: " . $this->tmpnaam;
echo "<br>";
}
function movefoto($uploadfoto)
{
if(file_exists($this->target.$this->naam)){
echo "Hernoem uw bestand aub";
exit();
}
if(in_array($this->type,$this->allowedfile)){
// get image
$image = @imagecreatefromjpeg($this->tmpnaam);
// Get original width and height
$width = imagesx($image);
$height = imagesy($image);
// New width and height
$new_height = 400;
$new_width = $width * ($new_height/$height);
// Resample
$image_resized = imagecreatetruecolor($new_width, $new_height);
imagecopyresampled($image_resized, $image, 0, 0, 0, 0, $new_width, $new_height, $width, $height);
if ($width > 600)
{
$percent = 0.55;
$new_width = $width * $percent;
$new_height = $height * $percent;
// Resample
$image_resized = imagecreatetruecolor($new_width, $new_height);
imagecopyresampled($image_resized, $image, 0, 0, 0, 0, $new_width, $new_height, $width, $height);
}
//save resized image to file
imagejpeg($image_resized, $this->target . $this->naam);
echo "U heeft uw bestand geupload";
}
else{
echo 'U kunt alleen Jpeg bestanden uploaden';
}
echo "<br>";
}
function showimage()
{
// Send header
header ('Content-Type: image/jpeg');
// Display image
imagejpeg($this->target . $this->naam);
}
}
?>
Gewijzigd op 01/01/1970 01:00:00 door jeffrey boud