Dodaj umjetnicki rub oko fotografije

This commit is contained in:
Senad Uka
2020-06-08 08:26:43 +02:00
parent 2a091f1f8a
commit 1f887bc359
5 changed files with 43 additions and 28 deletions

2
.gitignore vendored Normal file
View File

@@ -0,0 +1,2 @@
cache/*
slike/*

View File

@@ -62,6 +62,7 @@ $gotova_slika = $imagine->create($okvir_size, $color);
$gotova_slika->paste($okvir_image, new Imagine\Image\Point(0,0)); $gotova_slika->paste($okvir_image, new Imagine\Image\Point(0,0));
// snimi i prikazi // snimi i prikazi
// $gotova_slika->save(__DIR__ . "/cache/tip" . $okvir_id . "slika" . $slika . ".jpg")->show("jpg"); $gotova_slika->save(__DIR__ . "/cache/tip" . $okvir_id . "slika" . $slika . ".jpg");
$gotova_slika->show("jpg");
// koristiti CDN za kes // koristiti CDN za kes

12
index.html Normal file
View File

@@ -0,0 +1,12 @@
<!DOCTYPE html>
<html>
<body>
<form action="upload.php" method="post" enctype="multipart/form-data">
Izaberi sliku:
<input type="file" name="fileToUpload" id="fileToUpload">
<input type="submit" value="Upload Image" name="submit">
</form>
</body>
</html>

View File

@@ -29,30 +29,30 @@ $okvirovi = array (
); );
$radne_velicine = array( $radne_velicine = array(
0 => new Imagine\Image\Box(273, 362), 0 => new Imagine\Image\Box(153, 242),
1 => new Imagine\Image\Box(241, 354), 1 => new Imagine\Image\Box(221, 342),
2 => new Imagine\Image\Box(213, 317), 2 => new Imagine\Image\Box(93, 197),
3 => new Imagine\Image\Box(291, 404), 3 => new Imagine\Image\Box(171, 284),
4 => new Imagine\Image\Box(277, 389), 4 => new Imagine\Image\Box(157, 269),
5 => new Imagine\Image\Box(293, 426), 5 => new Imagine\Image\Box(173, 306),
6 => new Imagine\Image\Box(297, 427), 6 => new Imagine\Image\Box(177, 307),
7 => new Imagine\Image\Box(328, 437), 7 => new Imagine\Image\Box(208, 317),
8 => new Imagine\Image\Box(324, 440), 8 => new Imagine\Image\Box(204, 320),
9 => new Imagine\Image\Box(280, 418), 9 => new Imagine\Image\Box(160, 298),
10 => new Imagine\Image\Box(256, 362), 10 => new Imagine\Image\Box(136, 242),
11 => new Imagine\Image\Box(297, 425), 11 => new Imagine\Image\Box(177, 305),
12 => new Imagine\Image\Box(322, 430), 12 => new Imagine\Image\Box(202, 310),
13 => new Imagine\Image\Box(318, 448), 13 => new Imagine\Image\Box(198, 328),
14 => new Imagine\Image\Box(179, 247), 14 => new Imagine\Image\Box(59, 127),
15 => new Imagine\Image\Box(213, 288), 15 => new Imagine\Image\Box(93, 168),
16 => new Imagine\Image\Box(253, 387), 16 => new Imagine\Image\Box(133, 267),
17 => new Imagine\Image\Box(259, 395), 17 => new Imagine\Image\Box(139, 275),
18 => new Imagine\Image\Box(281, 402), 18 => new Imagine\Image\Box(161, 282),
19 => new Imagine\Image\Box(328, 433), 19 => new Imagine\Image\Box(208, 313),
20 => new Imagine\Image\Box(316, 423), 20 => new Imagine\Image\Box(196, 303),
21 => new Imagine\Image\Box(341, 458), 21 => new Imagine\Image\Box(221, 338),
22 => new Imagine\Image\Box(351, 439), 22 => new Imagine\Image\Box(231, 319),
23 => new Imagine\Image\Box(320, 454), 23 => new Imagine\Image\Box(200, 334),
); );
function rotiraj_za_90($box) { function rotiraj_za_90($box) {
@@ -60,7 +60,7 @@ function rotiraj_za_90($box) {
} }
function best_fit_odnos($box1, $box2) { function best_fit_odnos($box1, $box2) {
$odnos_sirina = $box1->getWidth() / $box2->getWidth(); $odnos_sirina = $box1->getWidth() / $box2->getWidth();
$odnos_duzina = $box1->getHeight() / $box2->getHeight(); $odnos_duzina = $box1->getHeight() / $box2->getHeight();
return min($odnos_sirina, $odnos_duzina); return min($odnos_sirina, $odnos_duzina);
} }

View File

@@ -27,8 +27,8 @@ foreach ($okvirovi as $okvir) {
$boja = $okvir_image->getColorAt(new Imagine\Image\Point($i, $j)); $boja = $okvir_image->getColorAt(new Imagine\Image\Point($i, $j));
// provjeri jel transparentna // provjeri jel transparentna
if($boja->getAlpha() < 90) { if($boja->getAlpha() < 90) {
$sirina = $okvir_size->getWidth() - (2 * $i); $sirina = $okvir_size->getWidth() - (2 * ($i + 60));
$duzina = $okvir_size->getHeight() - (2 * $j); $duzina = $okvir_size->getHeight() - (2 * ($j + 60));
// vrati velicinu povrsine // vrati velicinu povrsine
// pod pretpostavkom simetricnosti okvira // pod pretpostavkom simetricnosti okvira
echo "$okvirid => new Imagine\Image\Box($sirina, $duzina),\n"; echo "$okvirid => new Imagine\Image\Box($sirina, $duzina),\n";