Précédent   Forum des professionnels en informatique > PHP > Bibliothèques et frameworks > Images > Imagick
Imagick Forum d'entraide pour l'extension Imagick permettant de manipuler des images en PHP (port de l'API ImageMagick).
Partagez cette discussion sur d'autres réseaux sociaux : Viadeo Twitter Google Facebook Digg Delicious MySpace Yahoo
Réponse Proposer ce sujet en actualité
 
Outils de la discussion
Publicité
'
Vieux 22/03/2006, 17h17   #1
Futur Membre du Club
 
Inscription : février 2006
Messages : 56
Détails du profil
Informations forums :
Inscription : février 2006
Messages : 56
Points : 15
Points : 15
Par défaut [ImageMagick] imagefilledellipse : contours affreux

Bonjour,
J'utilise la fonction imagefilledellipse dans une focntion php pour creer une image.
Mais le resultat est tres crado !
Quelqu'un sait comment faire un anti-aliasing ou truc pour rendre le resultat plus beau ?
Merci.
ouquoi est déconnecté   Envoyer un message privé Réponse avec citation 00
Vieux 22/03/2006, 17h24   #2
Membre émérite

 
Avatar de FCYPBA
 
Inscription : novembre 2004
Messages : 735
Détails du profil
Informations personnelles :
Âge : 33
Localisation : France, Paris (Île de France)

Informations forums :
Inscription : novembre 2004
Messages : 735
Points : 924
Points : 924
En regardant un peu la doc, je trouve imageantialias

As toi de voir si cela te convient ou pas

M'enfin chercher dans la doc ne prends 1h et évite de poulluer le forum.

Pierre
FCYPBA est déconnecté   Envoyer un message privé Réponse avec citation 00
Vieux 22/03/2006, 17h53   #3
Futur Membre du Club
 
Inscription : février 2006
Messages : 56
Détails du profil
Informations forums :
Inscription : février 2006
Messages : 56
Points : 15
Points : 15
j'ai chercher dans la doc et antialias n'a eu aucun effet c'est pour ca que j'ai poster dans le forum.
ouquoi est déconnecté   Envoyer un message privé Réponse avec citation 00
Vieux 22/03/2006, 18h18   #4
Membre émérite

 
Avatar de FCYPBA
 
Inscription : novembre 2004
Messages : 735
Détails du profil
Informations personnelles :
Âge : 33
Localisation : France, Paris (Île de France)

Informations forums :
Inscription : novembre 2004
Messages : 735
Points : 924
Points : 924
Alors je ne vois pas,


Mais tu aurais du indiqué ce que tu avais essayé, cela aurait évité mon post un peu 'méchant'.
FCYPBA est déconnecté   Envoyer un message privé Réponse avec citation 00
Vieux 22/03/2006, 18h18   #5
Rédacteur
 
Avatar de Yogui
 
Homme Guillaume Rossolini
Directeur technique
Inscription : février 2004
Messages : 13 720
Détails du profil
Informations personnelles :
Nom : Homme Guillaume Rossolini
Localisation : France

Informations professionnelles :
Activité : Directeur technique

Informations forums :
Inscription : février 2004
Messages : 13 720
Points : 17 355
Points : 17 355
@FCYPBA : Merci de laisser la modération aux modérateurs

@ouquoi : En quel format envoies-tu ton image ? Perso, j'ai eu quelques soucis de qualité d'image avec le GIF, tandis que le JPEG passe bien.
__________________
Mes articles - Zend Certified Engineer (PHP + Zend Framework)
Ressources PHP - Ressources Zend Framework
Yogui est déconnecté   Envoyer un message privé Réponse avec citation 00
Vieux 22/03/2006, 22h26   #6
Rédacteur
 
Avatar de loka
 
Homme Romain PERRUCHON
Architecte - Expert Technique
Inscription : novembre 2004
Messages : 2 664
Détails du profil
Informations personnelles :
Nom : Homme Romain PERRUCHON
Âge : 30
Localisation : France, Loire Atlantique (Pays de la Loire)

Informations professionnelles :
Activité : Architecte - Expert Technique
Secteur : Service public

Informations forums :
Inscription : novembre 2004
Messages : 2 664
Points : 3 607
Points : 3 607
si tu pouvais nous montrer le resultat pour voir ce que tu trouves "crado" ^^
Pour moi le jpeg et le png passent plutot bien.
loka est déconnecté   Envoyer un message privé Réponse avec citation 00
Vieux 23/03/2006, 11h22   #7
Futur Membre du Club
 
Inscription : février 2006
Messages : 56
Détails du profil
Informations forums :
Inscription : février 2006
Messages : 56
Points : 15
Points : 15
ca resemble a ca :


Voila je trouve le cercle pas tres beau ...
ouquoi est déconnecté   Envoyer un message privé Réponse avec citation 00
Vieux 24/03/2006, 10h17   #8
Futur Membre du Club
 
Inscription : février 2006
Messages : 56
Détails du profil
Informations forums :
Inscription : février 2006
Messages : 56
Points : 15
Points : 15
Vous trouvez ca beau vous le contour du cercle ?
ouquoi est déconnecté   Envoyer un message privé Réponse avec citation 00
Vieux 24/03/2006, 10h22   #9
NoT
Membre confirmé
 
Inscription : février 2004
Messages : 237
Détails du profil
Informations forums :
Inscription : février 2004
Messages : 237
Points : 261
Points : 261
Nah.

Effectivement l'antialiasing a pas du passer, tu devrais poster ton code et préciser quelle version de GD tu utilises ?
NoT est déconnecté   Envoyer un message privé Réponse avec citation 00
Vieux 24/03/2006, 10h23   #10
Rédacteur
 
Avatar de Yogui
 
Homme Guillaume Rossolini
Directeur technique
Inscription : février 2004
Messages : 13 720
Détails du profil
Informations personnelles :
Nom : Homme Guillaume Rossolini
Localisation : France

Informations professionnelles :
Activité : Directeur technique

Informations forums :
Inscription : février 2004
Messages : 13 720
Points : 17 355
Points : 17 355
Ah, je vois mieux à quoi tu faisais référence ^^

Une solution pourrait consister en la création d'une image plus grande et de la réduire. Je n'ai pas testé mais il n'y a pas de raison...

[Edit] Tu as nien essayé avec imageantialias() ?
__________________
Mes articles - Zend Certified Engineer (PHP + Zend Framework)
Ressources PHP - Ressources Zend Framework
Yogui est déconnecté   Envoyer un message privé Réponse avec citation 00
Vieux 24/03/2006, 11h33   #11
Rédacteur
 
Avatar de loka
 
Homme Romain PERRUCHON
Architecte - Expert Technique
Inscription : novembre 2004
Messages : 2 664
Détails du profil
Informations personnelles :
Nom : Homme Romain PERRUCHON
Âge : 30
Localisation : France, Loire Atlantique (Pays de la Loire)

Informations professionnelles :
Activité : Architecte - Expert Technique
Secteur : Service public

Informations forums :
Inscription : novembre 2004
Messages : 2 664
Points : 3 607
Points : 3 607
oui en effet c'est pas beau
je pense que la solution de kirkis marche, si l'antiallias ne marche pas tu peux toujours te pencher dessus
loka est déconnecté   Envoyer un message privé Réponse avec citation 00
Vieux 24/03/2006, 11h52   #12
Futur Membre du Club
 
Inscription : février 2006
Messages : 56
Détails du profil
Informations forums :
Inscription : février 2006
Messages : 56
Points : 15
Points : 15
Pas de meilleur resultat avec la fonction antialias voici mon code :

Code :
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
 
function print_png_with_color($icone,$color,$bgcolor)
{
    $pixel_cadre = 40;
    $pixel_cercle = 20;
    $filename = ".\\images\\".$icone;
    $img = ImageCreateFromPng($filename);
    if($img == "")
    {
      echo "ERROR";
      return;
    }
 
    //Dimensions de l'image
    $imgWidth = imagesx($img) + $pixel_cadre;
    $imgHeight = imagesy($img)+ $pixel_cadre;
    $imgWidthCercle = imagesx($img) + $pixel_cercle;
    $imgHeightCercle = imagesy($img)+ $pixel_cercle;
 
    //Crée le thumb (image réduite)
    $imgComplete = ImageCreateTruecolor($imgWidth, $imgHeight);
 
    imageantialias( $imgComplete, True );
 
    $background = fromhex($bgcolor,$imgComplete);
 
    imagefill( $imgComplete, 0, 0,$background);
 
 
    $background = fromhex($bgcolor,$imgComplete);
 
    // couleur de remplissage de l'ellipse
    $col_ellipse = fromhex($color,$imgComplete);
 
    imagefilledellipse($imgComplete, $imgWidth/2, $imgHeight/2, $imgWidthCercle, $imgHeightCercle, $col_ellipse);
 
 
    $posx = $pixel_cadre / 2;
    ImageCopy($imgComplete,$img,$posx,$posx,0,0,$imgWidth-$pixel_cadre,$imgWidth-$pixel_cadre);
 
    // on affiche l'image
    header("Content-type: image/png");
    imagepng($imgComplete);
}
ouquoi est déconnecté   Envoyer un message privé Réponse avec citation 00
Vieux 24/03/2006, 13h37   #13
Rédacteur
 
Avatar de loka
 
Homme Romain PERRUCHON
Architecte - Expert Technique
Inscription : novembre 2004
Messages : 2 664
Détails du profil
Informations personnelles :
Nom : Homme Romain PERRUCHON
Âge : 30
Localisation : France, Loire Atlantique (Pays de la Loire)

Informations professionnelles :
Activité : Architecte - Expert Technique
Secteur : Service public

Informations forums :
Inscription : novembre 2004
Messages : 2 664
Points : 3 607
Points : 3 607
tu fais l'antialias avant la creation de l'elipse, je pense qu'il faudrait le faire après
loka est déconnecté   Envoyer un message privé Réponse avec citation 00
Vieux 24/03/2006, 13h40   #14
NoT
Membre confirmé
 
Inscription : février 2004
Messages : 237
Détails du profil
Informations forums :
Inscription : février 2004
Messages : 237
Points : 261
Points : 261
C'est ptet une connerie mais à mon avis l'antialiasing doit être placé plus loin dans ton code, je dirais meme juste avant de la renvoyer, quand tous les traitements ont été fait. ( juste avant ton image copy )

Essai et dis nous
NoT est déconnecté   Envoyer un message privé Réponse avec citation 00
Vieux 24/03/2006, 13h43   #15
Membre émérite

 
Avatar de FCYPBA
 
Inscription : novembre 2004
Messages : 735
Détails du profil
Informations personnelles :
Âge : 33
Localisation : France, Paris (Île de France)

Informations forums :
Inscription : novembre 2004
Messages : 735
Points : 924
Points : 924
Pour vérifier l'emplacement auquel il faut placer imageantialias, je découvre plein de chose sur cette fonction ( directive serait un terme plus approprié je pense)

Pour ma part, je pense que l'endroit ou il faut la placer n'a pas d'importance

par contre dans les notes de la fonctions, je découvre cette sympathique fonction utilisateur
Code :
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
 
The following function draws an AntiAliased (unfilled) Ellipse.
It is used just liked the nomral ImageEllipse function.
The optional parameter sets the number of segments...
 
function ImageEllipseAA( &$img, $x, $y, $w, $h,$color,$segments=70)
{
   $w=$w/2;
   $h=$h/2;
   $jump=2*M_PI/$segments;
   $oldx=$x+sin(-$jump)*$w;
   $oldy=$y+cos(-$jump)*$h;
   for($i=0;$i<2*(M_PI);$i+=$jump)
   {
       $newx=$x+sin($i)*$w;
       $newy=$y+cos($i)*$h;
       ImageLine($img,$newx,$newy,$oldx,$oldy,$color);
       $oldx=$newx;
       $oldy=$newy;
   }
}
A tester

Pierre
FCYPBA est déconnecté   Envoyer un message privé Réponse avec citation 00
Vieux 24/03/2006, 14h12   #16
Futur Membre du Club
 
Inscription : février 2006
Messages : 56
Détails du profil
Informations forums :
Inscription : février 2006
Messages : 56
Points : 15
Points : 15
Bon alors changer la position de l'antialias ne change rien.
Quand a la fonction ImageEllipseAA ce n'est pas plus fin voir pire meme avec 200000 segment ...
ouquoi est déconnecté   Envoyer un message privé Réponse avec citation 00
Vieux 29/03/2006, 16h01   #17
Rédacteur
 
Avatar de loka
 
Homme Romain PERRUCHON
Architecte - Expert Technique
Inscription : novembre 2004
Messages : 2 664
Détails du profil
Informations personnelles :
Nom : Homme Romain PERRUCHON
Âge : 30
Localisation : France, Loire Atlantique (Pays de la Loire)

Informations professionnelles :
Activité : Architecte - Expert Technique
Secteur : Service public

Informations forums :
Inscription : novembre 2004
Messages : 2 664
Points : 3 607
Points : 3 607
Je pense que la solution qu'il te reste pour le moment c'est d'essayer de faire une image plus grande et d'en faire un thumb avec imagecopyresampled()
loka est déconnecté   Envoyer un message privé Réponse avec citation 00
Vieux 11/03/2009, 22h51   #18
Invité de passage
 
Inscription : octobre 2008
Messages : 6
Détails du profil
Informations forums :
Inscription : octobre 2008
Messages : 6
Points : 2
Points : 2
Par défaut Script antialias pour les cercles ou les elipses

Bon la reponse tarde un peu, et c vrai que GD trace des cercles vraiment pas beau. Mais pour ceux qui passerai dans le coin, voici une fonction qui repond a ce forum.

Citation:
function imageSmoothCircle( &$img, $cx, $cy, $cr, $color ) {
$ir = $cr;
$ix = 0;
$iy = $ir;
$ig = 2 * $ir - 3;
$idgr = -6;
$idgd = 4 * $ir - 10;
$fill = imageColorExactAlpha( $img, $color[ 'R' ], $color[ 'G' ], $color[ 'B' ], 0 );
imageLine( $img, $cx + $cr - 1, $cy, $cx, $cy, $fill );
imageLine( $img, $cx - $cr + 1, $cy, $cx - 1, $cy, $fill );
imageLine( $img, $cx, $cy + $cr - 1, $cx, $cy + 1, $fill );
imageLine( $img, $cx, $cy - $cr + 1, $cx, $cy - 1, $fill );
$draw = imageColorExactAlpha( $img, $color[ 'R' ], $color[ 'G' ], $color[ 'B' ], 42 );
imageSetPixel( $img, $cx + $cr, $cy, $draw );
imageSetPixel( $img, $cx - $cr, $cy, $draw );
imageSetPixel( $img, $cx, $cy + $cr, $draw );
imageSetPixel( $img, $cx, $cy - $cr, $draw );
while ( $ix <= $iy - 2 ) {
if ( $ig < 0 ) {
$ig += $idgd;
$idgd -= 8;
$iy--;
} else {
$ig += $idgr;
$idgd -= 4;
}
$idgr -= 4;
$ix++;
imageLine( $img, $cx + $ix, $cy + $iy - 1, $cx + $ix, $cy + $ix, $fill );
imageLine( $img, $cx + $ix, $cy - $iy + 1, $cx + $ix, $cy - $ix, $fill );
imageLine( $img, $cx - $ix, $cy + $iy - 1, $cx - $ix, $cy + $ix, $fill );
imageLine( $img, $cx - $ix, $cy - $iy + 1, $cx - $ix, $cy - $ix, $fill );
imageLine( $img, $cx + $iy - 1, $cy + $ix, $cx + $ix, $cy + $ix, $fill );
imageLine( $img, $cx + $iy - 1, $cy - $ix, $cx + $ix, $cy - $ix, $fill );
imageLine( $img, $cx - $iy + 1, $cy + $ix, $cx - $ix, $cy + $ix, $fill );
imageLine( $img, $cx - $iy + 1, $cy - $ix, $cx - $ix, $cy - $ix, $fill );
$filled = 0;
for ( $xx = $ix - 0.45; $xx < $ix + 0.5; $xx += 0.2 ) {
for ( $yy = $iy - 0.45; $yy < $iy + 0.5; $yy += 0.2 ) {
if ( sqrt( pow( $xx, 2 ) + pow( $yy, 2 ) ) < $cr ) $filled += 4;
}
}
$draw = imageColorExactAlpha( $img, $color[ 'R' ], $color[ 'G' ], $color[ 'B' ], ( 100 - $filled ) );
imageSetPixel( $img, $cx + $ix, $cy + $iy, $draw );
imageSetPixel( $img, $cx + $ix, $cy - $iy, $draw );
imageSetPixel( $img, $cx - $ix, $cy + $iy, $draw );
imageSetPixel( $img, $cx - $ix, $cy - $iy, $draw );
imageSetPixel( $img, $cx + $iy, $cy + $ix, $draw );
imageSetPixel( $img, $cx + $iy, $cy - $ix, $draw );
imageSetPixel( $img, $cx - $iy, $cy + $ix, $draw );
imageSetPixel( $img, $cx - $iy, $cy - $ix, $draw );
}
}

$img = imageCreateTrueColor( 320, 240 );

imageSmoothCircle( $img, 160, 120, 100, array( 'R' => 0xCC, 'G' => 0x33, 'B' => 0x00 ) );
imageSmoothCircle( $img, 170, 110, 75, array( 'R' => 0xDD, 'G' => 0x66, 'B' => 0x00 ) );
imageSmoothCircle( $img, 180, 100, 50, array( 'R' => 0xEE, 'G' => 0x99, 'B' => 0x00 ) );
imageSmoothCircle( $img, 190, 90, 25, array( 'R' => 0xFF, 'G' => 0xCC, 'B' => 0x00 ) );

header( 'Content-Type: image/png' );
imagePNG( $img );
benland est déconnecté   Envoyer un message privé Réponse avec citation 00
Réponse Proposer ce sujet en actualité Cette discussion est résolue.
Outils de la discussion



Fuseau horaire GMT +2. Il est actuellement 23h56.


 
 
 
 
Partenaires

Hébergement Web