Witaj Gościu! ( Zaloguj | Rejestruj )

Forum PHP.pl

> [PHP][GD] Efekt "rybiego oka" na zdjęciu
patryk9200
post
Post #1





Grupa: Zarejestrowani
Postów: 319
Pomógł: 4
Dołączył: 7.02.2009
Skąd: pless

Ostrzeżenie: (0%)
-----


Cześć,
Jak utworzyć efekt "rybiego oka" na zdjęciu wykorzystując bibliotekę GD ?
Jak również utworzyć coś w rodzaju falowania?

czy ktoś wie jak to zrobić??
abo uzyskać podobne efekty?
Go to the top of the page
+Quote Post
2 Stron V   1 2 >  
Start new topic
Odpowiedzi (1 - 19)
flashdev
post
Post #2





Grupa: Zarejestrowani
Postów: 812
Pomógł: 117
Dołączył: 2.12.2008

Ostrzeżenie: (10%)
X----


Kiedys pisalem takie zabawki w różnych językach.
Masz tu coś w rodzaju JS:

Kod
// obraz zrodlowy oraz docelowy
// metody getPixel, oraz setPixel
source = new Image();
dest = new Image();

// wspolczynnik rybiego oka
factor = .7;
center = {x:width*.5, y:height*.5};
maxDist = dist(center.x, center.y);

for( i=0; i<width; i++){
    for( j=0; j<height; j++){
        angle = Math.atan2(j-center.y, i-center.x);
        newDist = mod(dist(i-center.x, j-center.y)/maxDist)*maxDist;
        color = source.getPixel(Math.sin(angle)*newDist, Math.cos(angle)*newDist);
        dest.setPixel(i, j, color);
    }
}

// funkcja przeksztalcajaca
// mozna zastosowac inna
function mod(x){
    return Math.pow(x, factor);
}

// oblicza dlugosc
function dist(x, y){
    return Math.sqrt(x*x+y*y);
}


Dodatkowo możesz pokusić się o interpolowanie pośrednich kolorów. Będzie dużo lepszy efekt.
I sprawdź czy nie ma gotowych bibliotek w php, takie operacje są bardzo powolne.


--------------------
Go to the top of the page
+Quote Post
patryk9200
post
Post #3





Grupa: Zarejestrowani
Postów: 319
Pomógł: 4
Dołączył: 7.02.2009
Skąd: pless

Ostrzeżenie: (0%)
-----


muszę to wykonać w PHP bo na podstawie tego chcę również zrobić captach'ę i znalazłem coś ciekawego:
http://www.fmwconcepts.com/imagemagick/bump/index.php
jak stworzyć coś takiego ?, mam bibliotekę Image Magick zainstalowaną na serwerze, tylko jak użyć ta funkcję?
Go to the top of the page
+Quote Post
erix
post
Post #4





Grupa: Moderatorzy
Postów: 15 467
Pomógł: 1451
Dołączył: 25.04.2005
Skąd: Szczebrzeszyn/Rzeszów




exec" title="Zobacz w manualu PHP" target="_manual i odpowiednia komenda na zapisanym na dysku obrazku.

Przykładowe parametry masz przecież podane...


--------------------

ZCE :: Pisząc PW załączaj LINK DO TEMATU i TYLKO w sprawach moderacji :: jakiś błąd - a TREŚĆ BŁĘDU? :: nie ponaglaj z odpowiedzią via PW!
Go to the top of the page
+Quote Post
patryk9200
post
Post #5





Grupa: Zarejestrowani
Postów: 319
Pomógł: 4
Dołączył: 7.02.2009
Skąd: pless

Ostrzeżenie: (0%)
-----


czyli co mam zrobić coś takiego że do komenty exec();
mam wstawić to coś?
kod
  1. <?php
  2. [left] USAGE: bump [-t type] [-a amplitude] [-r radius] [-c center] [-m] [-b bgcolor] infile outfile
  3. USAGE: bump [-h or -help]         [/left]
  4.          [left]         -t .... type ............. type of bump shaping; choices are:
  5.         .......................... 1=sinusoid, 2=triangle; 3=circular; default=1
  6.         -a .... amplitude ........ amplitude or elevation of the bump; float;
  7.         .......................... positive raises the bump; negative lowers
  8.         .......................... the depression; default=10
  9.         -r .... radius ........... radius from center point determines the extent of the bump;
  10.         .......................... integer>=0; default is half the minimum image dimension
  11.         -c .... center ........... center point for the bump; center=cx,cy;
  12.          .......................... integer>=0; default is center of image
  13.         -m ....................... mask the outside of the radius with background color
  14.         -b .... bgcolor .......... background color for the masked area outside the radius         [/left]
  15.          [left]         PURPOSE: To apply a hemispherical-like bump distortion to an image.         [/left]
  16.          [left]         DESCRIPTION: BUMP applies a hemispherical-like bump distortion to an image.          The user can control the amplitude or height of the bump, the radius of          the bump, the center point of the bump and the type of displacement profile          used to control the shape of the bump. This is a simpler approximation of          my bubblewarp script that is much faster due to the use of -distort          polar/depolar and a displacement map.         [/left]
  17.          [left]         ARGUMENTS:          [/left]
  18.          [left]         -t type ... TYPE of displacement profile used to control the shape of the bump.          Choices are: 1=sinusoid, 2=triangle; 3=circular; default=1         [/left]
  19.          [left]         -a amplitude ... AMPLITUDE or elevation of the bump. Values are floats.          Postive values raise the bump and negative values lower the elevation.          A value of zero produces essentially no change. The default=10.         [/left]
  20.          [left]         -r radius ... RADIUS is the radial distance from the center point which         determines the extent of the bump. Values are integers>=0. The default is          half the minimum dimension of the image.         [/left]
  21.          [left]         -c center ... CENTER=cx,cy are the comma separated coordinates in the image          determining the center of the bump. Values are integers>=0. The default          is the center of the image.         [/left]
  22.          [left]         -m ... Enables a mask around the bump that is set to the desired background          color. This gives the result a spherical or bubble effect.         [/left]
  23.          [left]         -b bgcolor ... BGOLOR is the color of the masked area outside the bump.          Any valid IM color is allowed. See <a href=&#092;"http://imagemagick.org/script/color.php\" target=\"_blank\">http://imagemagick.org/script/color.php</a>         The default=black.         [/left]
  24.          [left]         NOTE: Requires IM 6.4.2-8 or higher due to the use of -distort polar/depolar.          [/left]
  25.          [left]         CAVEAT: No guarantee that this script will work on all platforms,          nor that trapping of inconsistent parameters is complete and          foolproof. Use At Your Own Risk.          [/left]
  26. ?>
Go to the top of the page
+Quote Post
erix
post
Post #6





Grupa: Moderatorzy
Postów: 15 467
Pomógł: 1451
Dołączył: 25.04.2005
Skąd: Szczebrzeszyn/Rzeszów




Nie... dry.gif

Np:
  1. <?php
  2. exec('bump -potrzebny -parametr');
  3. ?>

nie pakuj wszystkich biggrin.gif


--------------------

ZCE :: Pisząc PW załączaj LINK DO TEMATU i TYLKO w sprawach moderacji :: jakiś błąd - a TREŚĆ BŁĘDU? :: nie ponaglaj z odpowiedzią via PW!
Go to the top of the page
+Quote Post
patryk9200
post
Post #7





Grupa: Zarejestrowani
Postów: 319
Pomógł: 4
Dołączył: 7.02.2009
Skąd: pless

Ostrzeżenie: (0%)
-----


a ten plik bump mam dać do katalogu gdzie go wykorzystuję?
Go to the top of the page
+Quote Post
erix
post
Post #8





Grupa: Moderatorzy
Postów: 15 467
Pomógł: 1451
Dołączył: 25.04.2005
Skąd: Szczebrzeszyn/Rzeszów




Nie. Jeśli piszesz, że masz na serwerze, to powinien on się bez problemu wywołać.


--------------------

ZCE :: Pisząc PW załączaj LINK DO TEMATU i TYLKO w sprawach moderacji :: jakiś błąd - a TREŚĆ BŁĘDU? :: nie ponaglaj z odpowiedzią via PW!
Go to the top of the page
+Quote Post
patryk9200
post
Post #9





Grupa: Zarejestrowani
Postów: 319
Pomógł: 4
Dołączył: 7.02.2009
Skąd: pless

Ostrzeżenie: (0%)
-----


zrobiłem coś takiego:
kod
  1. <?php
  2. $filename = 'test.jpg';
  3. $filesavename = 'test2.jpg';
  4.  
  5. exec('bump $filename -a -20 $filesavename');
  6. ?>

ale mi to nie działa... błędów też nie wywala...

czy problemem mogą być scieżki? mam takie:
  1. <?php
  2. /usr/local/bin/php  /home/test/ftp/
  3. ?>
Go to the top of the page
+Quote Post
Crozin
post
Post #10





Grupa: Zarejestrowani
Postów: 6 476
Pomógł: 1306
Dołączył: 6.08.2006
Skąd: Kraków

Ostrzeżenie: (0%)
-----


A zobacz sobie:
  1. <?
  2.  
  3. $var = 'value';
  4.  
  5. echo '$var';
  6. echo "$var";
  7. ?>
Go to the top of the page
+Quote Post
patryk9200
post
Post #11





Grupa: Zarejestrowani
Postów: 319
Pomógł: 4
Dołączył: 7.02.2009
Skąd: pless

Ostrzeżenie: (0%)
-----


Cytat(Crozin @ 27.07.2009, 15:26:25 ) *
A zobacz sobie:
  1. <?php
  2. $var = 'value';
  3.  
  4. echo '$var';
  5. echo &#092;"$var\";
  6. ?>

fakt zrobiłem gapę:P ale po poprawieniu ' ' na " " i tak nie działa...
Go to the top of the page
+Quote Post
Crozin
post
Post #12





Grupa: Zarejestrowani
Postów: 6 476
Pomógł: 1306
Dołączył: 6.08.2006
Skąd: Kraków

Ostrzeżenie: (0%)
-----


A co zwraca exec" title="Zobacz w manualu PHP" target="_manual? Jakiś komunikat?
Go to the top of the page
+Quote Post
patryk9200
post
Post #13





Grupa: Zarejestrowani
Postów: 319
Pomógł: 4
Dołączył: 7.02.2009
Skąd: pless

Ostrzeżenie: (0%)
-----


właśnie nic...
Go to the top of the page
+Quote Post
erix
post
Post #14





Grupa: Moderatorzy
Postów: 15 467
Pomógł: 1451
Dołączył: 25.04.2005
Skąd: Szczebrzeszyn/Rzeszów




A wykonanie tego polecenia na istniejących plikach z konsoli czymś skutkuje?


--------------------

ZCE :: Pisząc PW załączaj LINK DO TEMATU i TYLKO w sprawach moderacji :: jakiś błąd - a TREŚĆ BŁĘDU? :: nie ponaglaj z odpowiedzią via PW!
Go to the top of the page
+Quote Post
Crozin
post
Post #15





Grupa: Zarejestrowani
Postów: 6 476
Pomógł: 1306
Dołączył: 6.08.2006
Skąd: Kraków

Ostrzeżenie: (0%)
-----


Pokaż cały Twój obecny kod.
Go to the top of the page
+Quote Post
patryk9200
post
Post #16





Grupa: Zarejestrowani
Postów: 319
Pomógł: 4
Dołączył: 7.02.2009
Skąd: pless

Ostrzeżenie: (0%)
-----


robiłem na wiele sposobów i żaden nie zadziałał... oto kod:
  1. <?php
  2. $file['directory'] = '/images/';
  3. $file['dirsave'] = '/captcha/';
  4. $filename = './test.jpg';
  5. $filesavename = './test2.jpg';
  6.  
  7.  
  8.  
  9. exec("-bump $filename -a -20 $filesavename");
  10. $var = 'value';
  11.  
  12.  
  13. $path2im = '/usr/local/bin/convert';
  14. exec ("/usr/local/bin/convert -bump  -a -20 $filename  $filesavename");
  15.  
  16. $sourcepath = './test.jpg';
  17. $destpath = './test2.jpg';
  18. $path2im = '/usr/local/bin/convert';
  19. exec (' -bump  -a -20 ' . $sourcepath . ' ' . $destpath);
  20. ?>
Go to the top of the page
+Quote Post
golaod
post
Post #17





Grupa: Zarejestrowani
Postów: 419
Pomógł: 42
Dołączył: 12.08.2008
Skąd: Wrocław

Ostrzeżenie: (0%)
-----


Trochę ciężko ocenić czy exec coś zwraca skoro mu się nawet nie każe zwracać.

  1. <?php
  2. $exec = 'twoje komendy ktore wpisujesz tutaj 2>&1';
  3.        
  4. exec( $exec, $output );
  5.  
  6. print_r( $output );
  7. ?>


Ten post edytował golaod 27.07.2009, 15:19:15
Go to the top of the page
+Quote Post
Crozin
post
Post #18





Grupa: Zarejestrowani
Postów: 6 476
Pomógł: 1306
Dołączył: 6.08.2006
Skąd: Kraków

Ostrzeżenie: (0%)
-----


Jakbyś popatrzył do manuala to byś zauważył, że exec" title="Zobacz w manualu PHP" target="_manual() jako drugi i trzeci parametr przyjmują zmienne, do których zostanie zwrócony komunikat. Użyj tego i pokaż nam co zostało zwrócone.
Go to the top of the page
+Quote Post
patryk9200
post
Post #19





Grupa: Zarejestrowani
Postów: 319
Pomógł: 4
Dołączył: 7.02.2009
Skąd: pless

Ostrzeżenie: (0%)
-----


dziwne... zwróciło tylko Array ( )...
Go to the top of the page
+Quote Post
golaod
post
Post #20





Grupa: Zarejestrowani
Postów: 419
Pomógł: 42
Dołączył: 12.08.2008
Skąd: Wrocław

Ostrzeżenie: (0%)
-----


Pisałem wyżej... musisz dodać na końcu 2>&1
Go to the top of the page
+Quote Post

2 Stron V   1 2 >
Reply to this topicStart new topic
1 Użytkowników czyta ten temat (1 Gości i 0 Anonimowych użytkowników)
0 Zarejestrowanych:

 



RSS Aktualny czas: 21.08.2025 - 06:36