INSERT INTO "media_type" VALUES (7,'mpg','video/mpeg','Video','Video',NULL);
INSERT INTO "media_type" VALUES (9,'avi','video/x-msvideo','Video','Video',NULL);
INSERT INTO "media_type" VALUES (6,'pdf','application/pdf','Generic','Other',NULL);
-INSERT INTO "media_type" VALUES (15,'png','- deprecated -','Images','Images',NULL);
+INSERT INTO "media_type" VALUES (15,'png','image/png','ImagesPng','Images',NULL);
INSERT INTO "media_type" VALUES (3,'jpg','- deprecated -','Images','Images',NULL);
-INSERT INTO "media_type" VALUES (5,'jpg','image/*','Images','Images',NULL);
+INSERT INTO "media_type" VALUES (5,'jpg','image/*','ImagesJpeg','Images',NULL);
INSERT INTO "media_type" VALUES (16,'asf','video/x-ms-asf','Video','Video',NULL);
INSERT INTO "media_type" VALUES (17,'rm','application/vnd.rn-realmedia','RealVideo','Video',NULL);
INSERT INTO "media_type" VALUES (18,'mp3','audio/mpeg','Mp3','Audio',NULL);
+INSERT INTO "media_type" VALUES (19,'png','image/gif','ImagesPng','Images',NULL);
-- Enable triggers
UPDATE pg_class SET reltriggers = (SELECT count(*) FROM pg_trigger where pg_class.oid = tgrelid) WHERE relname = 'media_type';
// internal representation of the image
private PlanarImage planarImage;
+ // type of the image
+ private String _type;
+
// constructor
- public WebdbImage(byte[] image)
+ public WebdbImage(byte[] image, String type)
throws IOException
{
planarImage = JAI.create("stream",new ByteArraySeekableStream(image));
+ _type = type;
scaleImage();
}
- public WebdbImage(byte[] image, int iconMax)
+ public WebdbImage(byte[] image, String type, int iconMax)
throws IOException
{
maxIconSize=iconMax;
planarImage = JAI.create("stream",new ByteArraySeekableStream(image));
+ _type = type;
scaleImage();
}
- public WebdbImage(byte[] image, int iconMax, int imageMax)
+ public WebdbImage(byte[] image, String type, int iconMax, int imageMax)
throws IOException
{
maxIconSize=iconMax;
maxImageSize=imageMax;
planarImage = JAI.create("stream",new ByteArraySeekableStream(image));
+ _type = type;
scaleImage();
}
-
// acc3ssor-methods
public int getIconWidth() throws IOException {
if (iconData==null) scaleIcon();
public byte[] getImage() {
if (imageData==null) {
ByteArrayOutputStream outStream = new ByteArrayOutputStream();
- // @todo the choice of PNG or JPEG should be made configurable
- JAI.create("encode", planarImage, outStream, "JPEG", null);
+ JAI.create("encode", planarImage, outStream, _type, null);
imageData = outStream.toByteArray();
}
return imageData;
params.setParameter("interpolation",new InterpolationBilinear());
PlanarImage temp = JAI.create("scale", params);
ByteArrayOutputStream outStream = new ByteArrayOutputStream();
- // @todo the choice of PNG or JPEG should be made configurable
- JAI.create("encode", temp, outStream, "JPEG", null);
+ JAI.create("encode", temp, outStream, _type, null);
iconData = outStream.toByteArray();
iconWidth=temp.getWidth();
iconHeight=temp.getHeight();
return img_data;
}
- public void setImage(byte[] uploadData)
+ public void setImage(byte[] uploadData, String type)
throws StorageObjectException {
if (uploadData!=null) {
try {
theLog.printDebugInfo("settimage :: making internal representation of image");
- WebdbImage webdbImage= new WebdbImage(uploadData);
+ WebdbImage webdbImage= new WebdbImage(uploadData, type);
theLog.printDebugInfo("settimage :: made internal representation of image");
byte[] imageData = webdbImage.getImage();
theLog.printDebugInfo("settimage :: getImage");
*/
-public class MediaHandlerImages implements MirMedia
+public abstract class MediaHandlerImages implements MirMedia
{
- private static Logfile theLog = Logfile.getInstance(MirConfig.getProp("Home")+
+ static Logfile theLog = Logfile.getInstance(MirConfig.getProp("Home")+
"log/media.log");
+ static final String PNG = "PNG";
+ static final String JPEG = "JPEG";
+
+ abstract String getType();
public byte[] get(Entity ent, Entity mediaTypeEnt)
throws MirMediaException
throws MirMediaException {
try {
- ((EntityImages)ent).setImage(uploadData);
+ ((EntityImages)ent).setImage(uploadData, getType());
} catch ( StorageObjectException e) {
theLog.printError("MediaHandlerImages.set: "+e.toString());
throw new MirMediaException(e.toString());
--- /dev/null
+
+package mircoders.media;
+
+//import java.lang.*;
+//import java.io.*;
+//import java.util.*;
+//import java.lang.reflect.*;
+
+//import freemarker.template.SimpleList;
+
+import mir.media.*;
+//import mir.misc.*;
+
+/**
+ * This class handles saving, fetching creating representations
+ * for all JPeg images. The image content is stored in the DB. The content is
+ * written out to a file at the ProducerImages level.
+ * It implements the MirMedia interface.
+ * <p>
+ *
+ * @see mir.media.MirMedia
+ * @see mircoders.media.MediaHandlerImages
+ * @author mh
+ * @version 24.09.2001
+ */
+
+
+public class MediaHandlerImagesJpeg extends MediaHandlerImages implements MirMedia
+{
+ public String getType() {
+ return JPEG;
+ }
+
+}
--- /dev/null
+
+package mircoders.media;
+
+//import java.lang.*;
+//import java.io.*;
+//import java.util.*;
+//import java.lang.reflect.*;
+
+//import freemarker.template.SimpleList;
+
+import mir.media.*;
+//import mir.misc.*;
+
+/**
+ * This class handles saving, fetching creating representations
+ * for all png images. The image content is stored in the DB. The content is
+ * written out to a file at the ProducerImages level.
+ * It implements the MirMedia interface.
+ * <p>
+ *
+ * @see mir.media.MirMedia
+ * @see mircoders.media.MediaHandlerImages
+ * @author mh
+ * @version 24.09.2001
+ */
+
+
+public class MediaHandlerImagesPng extends MediaHandlerImages implements MirMedia
+{
+ public String getType() {
+ return PNG;
+ }
+
+}