Oracle MultiMedia Image
Version 11.2.0.2
 
General Information
Source {$ORACLE_HOME}/ord/im/admin

ordipksp.sql

ordsys.ORDImageConstants (package header)
ordsys.ORDImg_Pkg (package)
ordsys.ORDImgExtCodec_Pkg
ordsys.OrdImageSignature (type)
ordsys.ORDImage (type) - ordispec.sql
ordsys.ORDImageExceptions (pkg) - ordispec.sql (pkg header of exceptions)
Required Schemas
ORDPLUGINS ORDSYS SI_INFORMTN_SCHEMA
ordsys.ORDImage Columns
Column Name Data Type
SOURCE ordsys.ORDSOURCE
HEIGHT NUMBER(38)
WIDTH NUMBER(38)
CONTENTLENGTH NUMBER(38)
FILEFORMAT VARCHAR2(4000)
CONTENTFORMAT VARCHAR2(4000)
COMPRESSIONFORMAT VARCHAR2(4000)
MIMETYPE VARCHAR2(4000)
ordsys.ORDImage Methods
applyWatermark( ) image getHeight( ) ordImage()
applyWatermark( ) text getMetadata( ) process( )
checkProperties( ) getMimeType() processCopy( )
clearLocal() getProperties() processSourceCommand()
closeSource() getSource() putMetadata( )
copy( ) getSourceLocation() readFromSource()
deleteContent() getSourceName() setLocal()
export getSourceType() setMimeType()
getBFile() getUpdateTime() setProperties( )
getCompressionFormat( ) getWidth( ) setProperties( ) for foreign images
getContent() import( ) setSource()
getContentFormat( ) importFrom( ) setUpdateTime()
getContentLength( ) init() trimSource()
getDICOMMetadata() isLocal() writeToSource()
getFileFormat( ) openSource()  
ordsys.ORDSource Columns
Column Name Data Type
LOCALDATA BLOB
SRCTYPE VARCHAR2(4000)
SRCLOCATION VARCHAR2(4000)
SRCNAME VARCHAR2(4000)
UPDATETIME DATE
LOCAL NUMBER
Required System Privileges GRANT create any directory TO <schema_name>;
GRANT create any directory TO uwlass;
Sample Image File Click here to download demo1.jpg
Click here to download demo2.png
For the demo on this page copy demo.jpg to c:\temp or if on a real operating system to $HOME and make the appropriate change to the CREATE DIRECTORY DDL below.
 
MultiMedia Image Demo
Actions as SYS conn / as sysdba

ALTER USER ordsys ACCOUNT UNLOCK IDENTIFIED BY ordsys;
GRANT create session TO ordsys;

-- if an application schema does not already exist
CREATE USER uwclass
IDENTIFIED BY uwclass
DEFAULT TABLESPACE uwdata
TEMPORARY TABLESPACE temp
QUOTA 0 ON SYSTEM
QUOTA UNLIMITED ON uwdata;

GRANT create session TO uwclass;
GRANT create any directory TO uwclass;
GRANT create table TO uwclass;
GRANT create directory TO uwclass;
OrdImage Methods conn uwclass/uwclass

CREATE OR REPLACE DIRECTORY imagedir AS 'c:\temp';

-- verify required objects are visible to schema
SELECT owner, object_name, object_type, status
FROM all_objects
WHERE object_name LIKE 'ORD%IM%G%'
AND owner NOT IN ('OE', 'IX');

desc dba_type_methods

SELECT method_name, COUNT(*)
FROM dba_type_methods
WHERE type_name = 'ORDIMAGE'
GROUP BY method_name
ORDER BY 1;


conn ordsys/ordsys

col owner format a10
col library_name format a15
col file_spec format a55

desc all_libraries

SELECT *
FROM all_libraries;

-- explore what ordimage is
SELECT object_type
FROM user_objects
WHERE object_name = 'ORDIMAGE';

SELECT DISTINCT object_name
FROM user_arguments
WHERE package_name = 'ORDIMAGE'
ORDER BY 1;


conn uwclass/uwclass

CREATE TABLE t_image (
img_id NUMBER,
image  ordsys.ordimage);

desc t_image

set describe depth all linenum on indent on

desc t_image

-- create initial records
INSERT INTO t_image VALUES (1, ordsys.ordimage.init());
INSERT INTO t_image VALUES (2, ordsys.ordimage.init());
COMMIT;

-- this will fail
SELECT * FROM t_image;

SELECT img_id FROM t_image;

set serveroutput on

-- set all attributes
DECLARE
 obj ordsys.ordimage;
 ctx RAW(4000) := NULL;
BEGIN
  SELECT image
  INTO obj
  FROM t_image
  WHERE img_id = 1
  FOR UPDATE;

  obj.setSource('FILE', 'IMAGEDIR', 'demo1.jpg');
  -- import data
  obj.import(ctx);
  -- set image attributes in the IMAGE column metadata
  obj.setProperties;

  UPDATE t_image
  SET image = obj
  WHERE img_id = 1;

  SELECT image
  INTO obj
  FROM t_image
  WHERE img_id = 2
  FOR UPDATE;

  obj.setSource('FILE', 'IMAGEDIR', 'demo2.png');
  -- import data
  obj.import(ctx);
  -- set image attributes in the IMAGE column metadata
  obj.setProperties;

  -- checkProperties returns TRUE if the metadata matches the image
  IF obj.checkProperties() THEN
    dbms_output.put_line('TRUE');
  ELSE
    dbms_output.put_line('FALSE');
  END IF;

  UPDATE t_image
  SET image = obj
  WHERE img_id = 2;
END;
/

-- use SQL statements to access object metadata
col ImgCompression format a15

SELECT t.img_id, t.image.getCompressionFormat() ImgCompression
FROM t_image t;

col ImgFormat format a15

SELECT img_id, t.image.getContentFormat() ImgFormat
FROM t_image t;

col ByteSize format 9999999

SELECT t.img_id, t.image.getContentLength() ByteSize
FROM t_image t;

col FileType format a10

SELECT t.img_id, t.image.getFileformat() FileType
FROM t_image t;

col ImageSize format a20

SELECT t.img_id, t.image.getHeight() ||' x '|| t.image.getWidth() ||' pixels' ImageSize
FROM t_image t;

SELECT t.img_id, t.image.getMetadata() MetaData
FROM t_image t;

col MimeType format a20

SELECT t.img_id, t.image.getMimeType() MimeType
FROM t_image t;

col Src format a40

SELECT t.img_id, t.image.getSource() Src
FROM t_image t;

col SrcLocation format a15

SELECT t.img_id, t.image.getSourceLocation() SrcLocation
FROM t_image t;

col SrcName format a15

SELECT t.img_id, t.image.getSourceName() SrcName
FROM t_image t;

col SrcType format a15

SELECT t.img_id, t.image.getSourceType() SrcType
FROM t_image t;

SELECT t.img_id, t.image.getUpdatetime() UpdateTime
FROM t_image t;

-- display attributes using PL/SQL
set serveroutput on

DECLARE
 obj ordsys.ordImage;
 b   BLOB;
 c   CLOB;
 n1  NUMBER;
 n2  NUMBER;
 n3  NUMBER;
 v1  VARCHAR2(30);
 v2  VARCHAR2(30);
 v3  VARCHAR2(30);
 v4  VARCHAR2(30);
BEGIN
  SELECT image
  INTO obj
  FROM t_image
  WHERE img_id = 1;

  -- getContent Demo
  b := obj.getContent();
  dbms_output.put_line(dbms_lob.getlength(b));

  -- getProperties Overload 1 Demo taking as input the BLOB from getContent
  ordsys.ordImage.getProperties(b, c, v1, n1, n2, v2, v3, v4, n3);
  dbms_output.put_line('O1 C: ' || c);
  dbms_output.put_line('O1 V1: ' || v1);
  dbms_output.put_line('O1 N1: ' || n1);
  dbms_output.put_line('O1 N2: ' || n2);
  dbms_output.put_line('O1 V2: ' || v2);
  dbms_output.put_line('O1 V3: ' || v3);
  dbms_output.put_line('O1 V4: ' || v4);
  dbms_output.put_line('O1 N3: ' || n3);

  -- getProperties Overload 2 Demo taking as input the BLOB from getContent
  ordsys.ordImage.getProperties(b, c);
  dbms_output.put_line('O2 C: ' || c);
  dbms_output.put_line('O2 V1: ' || v1);

  -- getProperties Overload 3 and 4 mimic Overloads 1 and 2
  -- except they take a BFILE as input rather than a BLOB

END;
/

-- Apply Image Watermark
DECLARE
 src_image ordsys.ordImage;
 add_image ordsys.ordImage;
 dst_image ordsys.ordImage;
 prop_tab  ordsys.ord_str_list;
 logging   VARCHAR2(2000);
 orig_size VARCHAR2(100);
 new_size  VARCHAR2(100);
BEGIN
  SELECT t.image
  INTO add_image
  FROM t_image t
  WHERE t.img_id = 1;

  SELECT t.image
  INTO src_image
  FROM t_image t
  WHERE t.img_id = 2;

  INSERT INTO t_image
  VALUES (3, ordsys.ordimage.init());

  SELECT t.image
  INTO dst_image
  FROM t_image t
  WHERE t.img_id = 3
  FOR UPDATE;

  -- specify properties
  prop_tab := ordsys.ord_str_list('position=bottomcenter', 'transparency=0.3');

  -- add image watermark to source image
  src_image.applyWatermark(add_image, dst_image, logging, prop_tab);

  UPDATE t_image t
  SET image = dst_image
  WHERE t.img_id = 3;

  dbms_output.put_line('Logging: ' || logging);

  SELECT t.image.getHeight() ||' x '|| t.image.getWidth() ||' pixels'
  INTO orig_size
  FROM t_image t
  WHERE t.img_id = 2;

  SELECT t.image.getHeight() ||' x '|| t.image.getWidth() ||' pixels'
  INTO new_size
  FROM t_image t
  WHERE t.img_id = 3;

  dbms_output.put_line(orig_size);
  dbms_output.put_line(new_size);
END;
/
Apply Text Watermark -- ApplyWatermark Demo
DECLARE
 src_image ordsys.ordImage;
 add_text  VARCHAR2(200) := 'Morgan''s Library 2011';
 dst_image ordsys.ordImage;
 prop_tab  ordsys.ord_str_list;
 logging   VARCHAR2(2000);
 orig_size VARCHAR2(100);
 new_size  VARCHAR2(100);
BEGIN
  SELECT t.image
  INTO src_image
  FROM t_image t
  WHERE t.img_id = 2;

  INSERT INTO t_image
  VALUES (3, ordsys.ordimage.init());

  SELECT t.image
  INTO dst_image
  FROM t_image t
  WHERE t.img_id = 3
  FOR UPDATE;

  -- specify properties
  prop_tab := ordsys.ord_str_list('font_name=Arial', 'font_style=bold', 'font_size=10',
              'text_color=blue', 'position_x=100', 'position_y=100', 'transparency=0.6');

  -- add image watermark to source image
  src_image.applyWatermark(add_text, dst_image, logging, prop_tab);

  UPDATE t_image t
  SET image = dst_image
  WHERE t.img_id = 3;

  dbms_output.put_line('Logging: ' || logging);

  SELECT t.image.getHeight() ||' x '|| t.image.getWidth() ||' pixels'
  INTO orig_size
  FROM t_image t
  WHERE t.img_id = 2;

  SELECT t.image.getHeight() ||' x '|| t.image.getWidth() ||' pixels'
  INTO new_size
  FROM t_image t
  WHERE t.img_id = 3;

  dbms_output.put_line(orig_size);
  dbms_output.put_line(new_size);
END;
/
 
 
Morgan's Library Page Footer
This site is maintained by Dan Morgan. Last Updated: This site is protected by copyright and trademark laws under U.S. and International law. © 1998-2014 Daniel A. Morgan All Rights Reserved