ImageMagick + Debian

Tech-Online

New Member
Hallo,

ich bin gerade dabei auf einem Server "ImageMagick" zu installieren. Ich habe bis jetzt folgendes gemacht:

"apt-get install imagemagick"

ich dachte damit installiere ich das auch. Es kam kein Fehler und nichts. Wenn ich nun in PHP aber versuche damit Bilder zu verkleinern wird einfach nichts generiert.

Muss ich da noch was weiteres installieren oder muss ich da noch was konfigurieren?

Wäre nett, wenn mir jemand helfen könnte.

Gruß,
Tech-Online
 
Hallo,

Du willst wahrscheinlich stattdessen php5-imagick installieren.

ich habe gerade gesehen, dass ich das dann so machen muss: apt-get php5-imagick stimmt das? und ist das egal, dass ich vorher dann schon mal apt-get install imagemagick gemacht habe?

Gruß,
Tech-Online
 
ich habe gerade gesehen, dass ich das dann so machen muss: apt-get php5-imagick stimmt das? und ist das egal, dass ich vorher dann schon mal apt-get install imagemagick gemacht habe?

Da fehlt hinter apt-get noch ein "install". Wenn Du übrigens php4 statt php5 noch am laufen hast, wäre das Paket php4-imagick. Das andere Paket schadet nichts, das sind die Imagemagick-Binaries, während das hier das Imagemagick-PHP-Modul ist.
 
Hallo,

ich habe das gerade mal gemacht und bekomme jetzt folgende Meldung:

Code:
root@atom010:~# apt-get install php5-imagick
Reading package lists... Done
Building dependency tree... Done
php5-imagick is already the newest version.
0 upgraded, 0 newly installed, 0 to remove and 0 not upgraded.
root@atom010:~#

Mit freundlichen Grüßen,
Tech-Online
 
Code:
php5-imagick is already the newest version.
Das Paket ist bereits installiert. Du wirst also langsam mal Fehlermeldungen, Logs und deine Verwendung von ImageMagick präsentieren müssen.
Anderenfalls kann dir keiner Hilfe leisten.
 
Hallo,

ich habe in den Logs mal geschaut und ich bekomme imme wieder was:

[Thu Jan 08 17:58:55 2009] [error] [client 85.42.37.227] client sent HTTP/1.1 request without hostname (see RFC2616 section 14.23): /w00tw00t.at.ISC.SANS.DFind:)
sh: /convert: No such file or directory
sh: /convert: No such file or directory
[Thu Jan 08 18:49:10 2009] [error] [client 66.249.73.164] script '/var/www/vhosts/default/htdocs/index.php' not found or unable to stat
[Thu Jan 08 18:49:55 2009] [error] [client 66.249.73.164] script '/var/www/vhosts/default/htdocs/index.php' not found or unable to stat
[Thu Jan 08 18:50:56 2009] [error] [client 66.249.73.164] script '/var/www/vhosts/default/htdocs/index.php' not found or unable to stat

Aber das hier

sh: /convert: No such file or directory
sh: /convert: No such file or directory

kommt sehr sehr oft vor. Ich hoffe das sind die Infos die wichtig sind.

Gruß,
Tech-Online
 
Hallo,

vielen Dank für deine ganze Hilfe. Aber könntet du mir bitte noch eben sagen, wie ich das anpassen kann und vorallem wo ich das machen muss?

Gruß,
Tech-Online
 
Google und z.B. die Forensuche sind Dein Freund:

--marneus
 
Hallo,

so ich habe das nun folgendes gemacht:

<IfModule mod_php5.c>
php_admin_flag engine on
php_admin_flag safe_mode on
php_admin_value open_basedir "/var/www/vhosts/XX.de/httpdocs:/tmp:/usr/bin:/usr/share/php"
</IfModule>

dann habe ich

apache reload

gemacht, aber leider bringt das immer noch nichts. Was mache ich denn da falsch?

Gruß,
Tech-Online
 
Hallo,

das ist die Funktion:

PHP:
  function scaleImage($URL, $Options)
  {
    $URL = str_replace('media/', 'media/_generate/', $URL);
    $URL = str_replace('img/', 'img/_generate/', $URL);
    $URL = explode('.', $URL);
    $Extension = array_pop($URL);
    $URL[] = $Options;
    $URL[] = $Extension;

    return $URL = implode('.', $URL);
    return '/media/_generate/MissingFile.php?Rewrite_Uri=' . $URL;

    //        return implode('.', $URL);
  }
}

so rufe ich dann das Bild auf:

PHP:
<img src="<?php print FI::scaleImage($record->logo, 'w150.h125') ?>" align="right" style="
      margin-left: 10px; border: 1px solid black; 
      " />

Gruß,
Tech-Online
 
Hallo,

achso dann das hier:

PHP:
        $JpegQuality = 85;
        if (!empty($this->Width) and !empty($this->Height))
        {
            if (true == $this->CropHorizontally)
            {
                $Command =
                    'convert' .
//                    ' -size ' . ($this->Width * 3) . 'x' . ($this->Height * 3) .
//                    ' ' . str_replace('/', '\\', $this->InputFile) . 
                    ' "' . str_replace('/', '\\', $this->InputFile) . '"' .
                    ' -thumbnail x' .($this->Height * 2) .
                    ' -resize "' . ($this->Width * 2) . 'x<"' .
                    ' -resize 50%' .
//                    ' -gravity north' .
                    ' -crop ' . $this->Width . 'x' . $this->Height . '+0+0' .
                    ' +repage -quality ' . $JpegQuality . 
                    ' "' . str_replace('/', '\\', $this->OutputFile) . '"'
                    ;
            }
            elseif (true === $this->CropVertically)
            {
                $Command =
                    'convert' .
//                    ' -size ' . ($this->Width * 3) . 'x' . ($this->Height * 3) .
//                    ' ' . str_replace('/', '\\', $this->InputFile) . 
                    ' "' . str_replace('/', '\\', $this->InputFile) . '"' .
                    ' -thumbnail ' .($this->Width * 2) . 'x' .
                    ' -resize "x' . ($this->Heigth * 2) . '<"' .
                    ' -resize 50%' .
//                    ' -gravity north' .
                    ' -crop ' . $this->Width . 'x' . $this->Height . '+0+0' .
                    ' +repage -quality ' . $JpegQuality . 
                    ' -interlace Line ' .
                    ' "' . str_replace('/', '\\', $this->OutputFile) . '"'
                    ;
            }
            elseif (true === $this->FillBlankArea)
            {
                $Command =
                    'convert ' .
//                    ' \(' .
                        '"' . str_replace('/', '\\', $this->InputFile) . '"' .
                        ' -resize "' . ($this->Width) . 'x' . ($this->Height) .'" ' .
//                    ' \)' .
//                    ' \(' .
                        ' -size "' . ($this->Width) . 'x' . ($this->Height) . '" ' .
                        ' xc:white' .
//                    ' \)' .
                    ' +swap' .
                    ' -gravity center' .
                    ' -composite' .
//                    ' -compose over' .
//                    ' -quality ' . $JpegQuality . ' ' .
                    ' -interlace Line ' .
                    ' "' . str_replace('/', '\\', $this->OutputFile) . '"' .
                    '';
            }
            else
            {
                $Command =
                    'convert' .
//                    ' -size ' . ($this->Width * 3) . 'x' . ($this->Height * 3) .
//                    ' ' . str_replace('/', '\\', $this->InputFile) . 
                    ' "' . str_replace('/', '\\', $this->InputFile) . '"' .
                    ' -thumbnail "' . $this->Width . 'x' . $this->Height .'>"' .
//                    ' -resize "' . ($this->Width * 2) . 'x<"' .
//                    ' -resize 50%' .
                    ' -gravity north' .
//                    ' -crop ' . $this->Width . 'x' . $this->Height . '+0+0' .
                    ' +repage -quality ' . $JpegQuality . 
                    ' -interlace Line ' .
                    ' "' . str_replace('/', '\\', $this->OutputFile) . '"'
                    ;
            }
        }
        else
        {
            $Command =
                'convert ' .
//                '-size ' . ($this->Width) . 'x' . ($this->Height) .' ' .
                '-resize ' . ($this->Width) . 'x' . ($this->Height) .' ' .
                '-quality ' . $JpegQuality . ' ' .
                ' "' . str_replace('/', '\\', $this->InputFile) . '"' .
                ' -interlace Line ' .
                ' "' . str_replace('/', '\\', $this->OutputFile) . '"';
        }
//        print $Command =
//            'convert' .
//            ' -size ' . ($this->Width) . 'x' . ($this->Height) .' ' . str_replace('/', '\\', $this->InputFile) .
//            ' -thumbnail "' . $this->Width . 'x' . $this->Height .'>"' .
//            ' -bordercolor skyblue' .
//            ' -border 50' .
//            ' -gravity center' .
//            ' -crop ' . $this->Width . 'x' . $this->Height .'+0+0' .
//            ' +repage ' . str_replace('/', '\\', $this->OutputFile)
//            ;
//        $Command =
//            'montage ' .
//            '-background #ffffff ' .
//            '-resize ' . $this->Width . 'x' . $this->Height .' ' .
//            str_replace('/', '\\', $this->InputFile) . ' ' .
//            str_replace('/', '\\', $this->OutputFile);

        $Command = str_replace('\\', DIRECTORY_SEPARATOR, $Command);
        print $Command . "\n<br />";
        
        print exec($Command);
        /* Add redirection so we can get stderr. */
//        $handle = popen($Command, 'r');
//        echo "'$handle'; " . gettype($handle) . "\n";
//        $read = fread($handle, 2096);
//        echo $read;
//        pclose($handle);

        $this->DebugOutput = ob_get_clean();
    }

    protected function alignVertically($Style, &$ImagePath)
    {
//        print '$this->Src'."\n";
//        print_r($this->Src);
//
//        print '$this->Dest'."\n";
//        print_r($this->Dest);
//
//        print '$ImagePath[Size][1] :: ' . $this->Src->GIS[1] ."\n";
//        print '$this->Src->Height :: ' . $this->Src->Height ."\n";
//        print '$this->Src->Y :: ' . $this->Src->Y ."\n";

        switch ($Style)
        {
            case 'center' :
//                $HeightToCompose = $this->Src->GIS[1] / 2 - $this->Src->Height / 2;
//                $this->Src->Y = $this->Src->Y - $HeightToCompose / 2;
                $this->Src->Y = $this->Src->GIS[1] / 2 - $this->Src->Height / 2;
                break;
        }

//        print '$HeightToCompose :: ' . $HeightToCompose ."\n";
//        print '$this->Src->Height :: ' . $this->Src->Height ."\n";
//        print '$this->Src->Y :: ' . $this->Src->Y ."\n";
    }

Gruß,
Tech-Online
 
Hallo,

wenn ich ehrlich bin dann weis ich nicht was du mir damit sagen willst. Ich habe das Projekt von einem anderen Server übernommen da lief das ohne Probleme, das war ein Suse Linux Server. Warum geht das hier denn nicht? Ist Debian und Suse so verschieden?

Kannst du mir denn bitte sagen wo ich was ändern muss?

Gruß,
Tech-Online
 
Ist Debian und Suse so verschieden?
Zumindest die Effektive PATH-Variable scheint anders zu sein. In den geposteten Fehlermeldungen wurde das Fehlen von /convert bemängelt.

Kannst du mir denn bitte sagen wo ich was ändern muss?
Mach, dass das Script convert mit dem _absoluten Pfad_ aufruft. (Hatte ich schonmal geschrieben.)
Man benutzt i.d.R. immer absolute Pfade. Entweder fest codiert oder ermittelt. Aber einfach so in Blaue hinein einen Dateinamen zu starten ist keine gute Idee.

Das mit dem sprintf und escapeshellargs war nur ein allgemeiner Rat. Bei der einfachen Konkatenation von Strings und Variablen besteht immer das Risiko, dass etwas in den Shellaufruf durchschlägt, das potentiell gefährlich ist.
Mit sprintf und escapeshellarg kann man numerische und alphanumerische Werte entschärfen.
 
Hallo,

so hab mal ein weing hier im Forum gesucht und habe das hier gefunden:

ich denke ich muss das dann auch in mein Script einfügen das dann so aussieht oder?

PHP:
            if (true == $this->CropHorizontally)
            {
                $Command =
                    '/usr/bin/convert' .
//                    ' -size ' . ($this->Width * 3) . 'x' . ($this->Height * 3) .


EDIT:
Ich habe das nun mal so gemacht aber leider sagt mein Error.log immer noch das gleiche wie auch gestern, dass er also den /convert nicht findet
 
Last edited by a moderator:
Back
Top