Schrift
[thread]779[/thread]

Piktogramme erzeugen: >alle Files im Verzeichnis verarbeiten<



<< >> 4 Einträge, 1 Seite
suliko
 2006-07-19 14:07
#8386 #8386
User since
2006-04-26
23 Artikel
BenutzerIn
[default_avatar]
Hallo!

Ich möchte in einem Verzeichnis alle Bilddateiein bearbeiten und mache ich es sorum:

Code: (dl )
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
#!C:\Perl\bin\perl.exe

use strict 'vars';
use Env;
use CGI::Carp qw(fatalsToBrowser);
use Image::Magick;

print <<BLOCK;
Content-type: text/html

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">


<body bgcolor="#400014" text="#00d8fc">

BLOCK

my($image, $x, $file);

$image = Image::Magick->new;

my $dirname = join('/', "$ENV{'DOCUMENT_ROOT'}", 'local/');
my $dirname2 = join('/', "$ENV{'DOCUMENT_ROOT'}", 'thumbs/');

opendir(DIR, $dirname);

while (defined($file = readdir(DIR))) {

next if $file =~ /^\.\.?$/;

print <<BLOCK;
<p><span style="font-family:tahoma, verdana, monospace; font-size:80%; font-weight: normal">$dirname$file</span></p>
BLOCK

$x = $image->Read('$file');
warn "$x" if "$x";

$x = $image->Crop(geometry=>'90x90+100+100');
warn "$x" if "$x";

$x = $image->Write('$dirname2$file');
warn "$x" if "$x";

print <<BLOCK;
<img src="$dirname2$file" border="1px" bcolor="#00d8fc" alt="$dirname2$file"><br>
BLOCK

}

closedir(DIR);

print <<BLOCK;

</body>
</html>

BLOCK


Was mache ich falsch, wenn ich keine Piktogramme im thumbs-Verzeichnis erzeugt bekomme?

Danke für Tipps!
:::bona mente:::
GwenDragon
 2006-07-19 14:54
#8387 #8387
User since
2005-01-17
14563 Artikel
Admin1
[Homepage]
user image
Code: (dl )
1
2
use strict;
use warnings;
wäre vielleicht sinnvoller ;)

Du prüfst ja noch nicht einmal, ob das opendir klappt!
Code: (dl )
opendir(DIR, $dirname) or die ("Cannot open $dirname");

Du prüfst nicht, ob
Code: (dl )
Image::Magick->new;
klappt und nicht fehlschlägt.
die Drachin, Gwendolyn


Unterschiedliche Perl-Versionen auf Windows (fast wie perlbrew) • Meine Perl-Artikel

renee
 2006-07-19 15:12
#8388 #8388
User since
2003-08-04
14371 Artikel
ModeratorIn
[Homepage] [default_avatar]
Hast Du Schreibrechte für das Verzeichnis?

Und das hier ist auch nicht richtig:
Code: (dl )
    $x = $image->Write('$dirname2$file');


Lass die ' mal weg!
OTRS-Erweiterungen (http://feature-addons.de/)
Frankfurt Perlmongers (http://frankfurt.pm/)
--

Unterlagen OTRS-Workshop 2012: http://otrs.perl-services.de/workshop.html
Perl-Entwicklung: http://perl-services.de/
suliko
 2006-07-19 17:17
#8389 #8389
User since
2006-04-26
23 Artikel
BenutzerIn
[default_avatar]
Danke!

Ich habe mein Skript etwas verbessert:

Code: (dl )
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
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
#!C:\Perl\bin\perl.exe

use strict;
use warnings;
use Env;
use CGI::Carp qw(fatalsToBrowser);
use Image::Magick;

sub GetLayoutName;

my $CSSFILE = &GetLayoutName();

print <<BLOCK;
Content-type: text/html

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>::test::</title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta http-equiv="Content-Style-Type" content="text/css" />
<meta http-equiv="expires" content="now" />
<meta http-equiv="pragma" content="no-cache" />
<meta http-equiv="cache-control" content="no-cache" />
<meta http-equiv="cache-control" content="no-store" />
<meta name="author" content="xxx" />
<meta name="description" content="xxx" />
<meta name="date" content="xxx" />
<meta name="robots" content="index,follow" />
<link rel="stylesheet" type="text/css" href="../outlook/$CSSFILE" />
<style type="text/css" title="currentStyle" media="screen">\@import "../outlook/$CSSFILE";</style>
</head>

<body class="all">

BLOCK

my($image, $x, $file);

my $neufile = 'n.jpg';

$image = Image::Magick->new;

my $dirname = join('/', "$ENV{'DOCUMENT_ROOT'}", 'local');
my $dirname2 = join('/', "$ENV{'DOCUMENT_ROOT'}", 'thumbs', "$neufile");

opendir(DIR, $dirname) or die ("Cannot open $dirname");

while (defined($file = readdir(DIR))) {

next if $file =~ /^\.\.?$/;

$file = join('/', "$dirname", "$file");

print <<BLOCK;

<br>Woher: $dirname Was: $file Wohin: $dirname2<br>

BLOCK

$x = $image->Read($file);
warn "$x" if "$x";

$x = $image->Crop(geometry=>'90x90+275+195');
warn "$x" if "$x";

$x = $image->Write($dirname2);
warn "$x" if "$x";

}

closedir(DIR);

my $thumbFile = 'noname.jpg';
my $thumbsDir = join('/', "$ENV{'DOCUMENT_ROOT'}", 'thumbs/');

opendir(DIR, $thumbsDir) or die ("Cannot open $thumbsDir");

while (defined($thumbFile = readdir(DIR))) {

next if $thumbFile =~ /^\.\.?$/;

print <<BLOCK;
<table>
<td><img src="../thumbs/$thumbFile" border="1px" bcolor="#00d8fc" alt="$thumbFile"><br></td>
</table>
BLOCK

}

closedir(DIR);

print <<BLOCK;

</body>
</html>

BLOCK

# ================================================================================
# GetLayoutName
# ================================================================================
sub GetLayoutName {

use Env;

$ENV{'HTTP_USER_AGENT'} =~ /(MSIE|Opera|Firefox)/;

my $BrowserName = $1;
my $LayoutName = "msie.css";

if ($BrowserName eq "Opera") {

$LayoutName = "opera.css";

} elsif ($BrowserName eq "Firefox") {

$LayoutName = "firefox.css";

} elsif ($BrowserName eq "Netscape") {

$LayoutName = "netscape.css";

} else {}

return $LayoutName;
}


Leider läuft die while-Schleife ein Mal zu viel... :-/
:::bona mente:::
<< >> 4 Einträge, 1 Seite



View all threads created 2006-07-19 14:07.