2年前,我提供了一个的可用版,gif4j是一套针对gif操作的java类库。
周末无聊,最终破解了gif4j的"eval gif4j"。
import
com.gif4j.
*
;
import
java.awt.
*
;
import
java.awt.image.bufferedimage;
import
java.io.file;
import
java.io.ioexception;
public
class
gifimagewatermarkexample {
//
usage: java gifimagewatermarkexample [pathtogifimagetowatermark] (please be sure that the gif4j jar is in your classpath)
//
by default the gif4j_logotype.gif as an example gif image is used
public
static
void
main(string[] args) {
file gifimagefiletowatermark
=
null
;
if
(args.length
==
0
) {
gifimagefiletowatermark
=
new
file(
"
test.gif
"
);
}
else
gifimagefiletowatermark
=
new
file(args[
0
]);
//
load and decode gif image
gifimage gifimage
=
null
;
try
{
gifimage
=
gifdecoder.decode(gifimagefiletowatermark);
}
catch
(ioexception e) {
e.printstacktrace();
system.exit(
1
);
}
//
change out directory if it is necessary
file outputdir
=
new
file(
"
.
"
file.separator
"
result
"
);
if
(
!
outputdir.exists())
outputdir.mkdirs();
//
create watermark image using textpainter
textpainter painter
=
new
textpainter(
new
font(
"
verdana
"
, font.bold,
10
));
painter.setoutlinepaint(color.white);
bufferedimage watermarkimage
=
painter.renderstring(
"
david.turing
"
,
true
);
//
create watermark
watermark watermark
=
new
watermark(watermarkimage, watermark.layout_top_left,
0.2f
);
//
apply watermark
gifimage topleftwatermarked
=
watermark.apply(gifimage,
true
);
//
apply watermark smoothly
gifimage topleftwatermarked_smoothly
=
watermark.apply(gifimage,
true
);
//
change the watermark alignment
watermark.setlayoutconstraint(watermark.layout_middle_center);
//
apply watermark
gifimage middlecenterwatermarked
=
watermark.apply(gifimage,
false
);
//
apply watermark smoothly
gifimage middlecenterwatermarked_smoothly
=
watermark.apply(gifimage,
true
);
//
change the watermark alignment
watermark.setlayoutconstraint(watermark.layout_bottom_right);
//
apply watermark
gifimage bottomrightwatermarked
=
watermark.apply(gifimage,
false
);
//
apply watermark smoothly
gifimage bottomrightwatermarked_smoothly
=
watermark.apply(gifimage,
true
);
//
change the watermark alignment
watermark.setlayoutconstraint(watermark.layout_cover_consecutively);
//
change the watermark transparency
watermark.settransparency(
0.20f
);
//
apply watermark
gifimage coverconswatermarked
=
watermark.apply(gifimage,
false
);
//
apply watermark smoothly
gifimage coverconswatermarked_smoothly
=
watermark.apply(gifimage,
true
);
//
save the results
try
{
gifencoder.encode(topleftwatermarked,
new
file(outputdir,
"
topleftwatermarked.gif
"
));
gifencoder.encode(topleftwatermarked_smoothly,
new
file(outputdir,
"
topleftwatermarked_smooth.gif
"
));
gifencoder.encode(middlecenterwatermarked,
new
file(outputdir,
"
middlecenterwatermarked.gif
"
));
gifencoder.encode(middlecenterwatermarked_smoothly,
new
file(outputdir,
"
middlecenterwatermarked_smooth.gif
"
));
gifencoder.encode(bottomrightwatermarked,
new
file(outputdir,
"
bottomrightwatermarked.gif
"
));
gifencoder.encode(bottomrightwatermarked_smoothly,
new
file(outputdir,
"
bottomrightwatermarked_smooth.gif
"
));
gifencoder.encode(coverconswatermarked,
new
file(outputdir,
"
coverconswatermarked.gif
"
));
gifencoder.encode(coverconswatermarked_smoothly,
new
file(outputdir,
"
coverconswatermarked_smooth.gif
"
));
}
catch
(ioexception e) {
e.printstacktrace();
}
}
}
下面是运行的结果:
破解的包放在我的usergroup下载: