git://git.nikiroo.be
/
fanfix.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Check for the localized changelog to show
[fanfix.git]
/
src
/
be
/
nikiroo
/
fanfix
/
output
/
InfoCover.java
diff --git
a/src/be/nikiroo/fanfix/output/InfoCover.java
b/src/be/nikiroo/fanfix/output/InfoCover.java
index 74505e7dd72bc4b290feb801ab7c588166a0280e..1e6ccd3363f49cf210e45c28ea2a66d5fa3eae2e 100644
(file)
--- a/
src/be/nikiroo/fanfix/output/InfoCover.java
+++ b/
src/be/nikiroo/fanfix/output/InfoCover.java
@@
-1,20
+1,21
@@
package be.nikiroo.fanfix.output;
package be.nikiroo.fanfix.output;
+import java.io.BufferedWriter;
import java.io.File;
import java.io.File;
-import java.io.File
Writer
;
+import java.io.File
OutputStream
;
import java.io.IOException;
import java.io.IOException;
-
-import javax.imageio.ImageIO;
+import java.io.OutputStreamWriter;
import be.nikiroo.fanfix.Instance;
import be.nikiroo.fanfix.bundles.Config;
import be.nikiroo.fanfix.data.MetaData;
import be.nikiroo.fanfix.Instance;
import be.nikiroo.fanfix.bundles.Config;
import be.nikiroo.fanfix.data.MetaData;
-class InfoCover {
+
public
class InfoCover {
public static void writeInfo(File targetDir, String targetName,
MetaData meta) throws IOException {
File info = new File(targetDir, targetName + ".info");
public static void writeInfo(File targetDir, String targetName,
MetaData meta) throws IOException {
File info = new File(targetDir, targetName + ".info");
- FileWriter infoWriter = new FileWriter(info);
+ BufferedWriter infoWriter = new BufferedWriter(new OutputStreamWriter(
+ new FileOutputStream(info), "UTF-8"));
if (meta != null) {
try {
if (meta != null) {
try {
@@
-51,6
+52,11
@@
class InfoCover {
}
writeMeta(infoWriter, "EPUBCREATOR", BasicOutput.EPUB_CREATOR);
writeMeta(infoWriter, "PUBLISHER", meta.getPublisher());
}
writeMeta(infoWriter, "EPUBCREATOR", BasicOutput.EPUB_CREATOR);
writeMeta(infoWriter, "PUBLISHER", meta.getPublisher());
+ writeMeta(infoWriter, "WORDCOUNT",
+ Long.toString(meta.getWords()));
+ writeMeta(infoWriter, "CREATION_DATE", meta.getCreationDate());
+ writeMeta(infoWriter, "FAKE_COVER",
+ Boolean.toString(meta.isFakeCover()));
} finally {
infoWriter.close();
}
} finally {
infoWriter.close();
}
@@
-61,20
+67,18
@@
class InfoCover {
MetaData meta) {
if (meta != null && meta.getCover() != null) {
try {
MetaData meta) {
if (meta != null && meta.getCover() != null) {
try {
- String format = Instance.getConfig()
- .getString(Config.IMAGE_FORMAT_COVER).toLowerCase();
- ImageIO.write(meta.getCover(), format, new File(targetDir,
- targetName + "." + format));
+ Instance.getCache().saveAsImage(meta.getCover(),
+ new File(targetDir, targetName), true);
} catch (IOException e) {
// Allow to continue without cover
} catch (IOException e) {
// Allow to continue without cover
- Instance.
syserr(new IOException
(
- "Failed to save the cover image", e));
+ Instance.
getTraceHandler().error
(
+
new IOException(
"Failed to save the cover image", e));
}
}
}
}
}
}
- private static void writeMeta(
FileWriter writer, String key, String value)
- throws IOException {
+ private static void writeMeta(
BufferedWriter writer, String key,
+
String value)
throws IOException {
if (value == null) {
value = "";
}
if (value == null) {
value = "";
}