| Location | |
| How to place the applet on a web page. | this document |
| How to implement the saving script | this document |
| How to accept images having a predefined size | this document |
| How to create the image's thumbnail | this document |
| How to delete image files automatically | this document |
| How to process large images | this document |
| How to print from the applet | this document |
| How to control NetImaging in JavaScript | this document |
| Customizing the GUI and localization | this document |
| The list of parameters | this document |
| Compatibility notes | this document |
| The product's home page | web |
The minimal HTML code to place the applet on a web page might look as follows:
<applet width="640" height="480" codebase="./applet/" archive="imaging.jar" code="Main.class"> <param name="load" value="myimage.jpg"> <param name="save" value="save.php"> </applet>
The attributes width and height might be set according to your page design
but you should provide enough room for the applet controls.
The attribute codebase should point to the applet's directory specified either as it's absolute URL
or relative to the current HTML page, for example:
The applet parameters are specified by the tags <param>. All the parameters are optional but to be useful the applet needs at least the two:
The section The list of parameters describes others parameters that allow you to customize the applet's GUI, apply different image constraints, etc. |
When the user presses
button,
the applet uploads the image to the server requesting the script specified by the paramater "save".
The request looks as if it's made by a regular HTML upload form like the following:
<form method="post" action="save.php" enctype="multipart/form-data" >
<input type="file" name="image">
<input type="text" name="width">
<input type="text" name="height">
<input type="submit">
</form>
The image is passed as the value the field image. Along with the image itself the applet posts the image's width and height.
#COMMAND=parameter
#SETDOCTAG=_blank #SHOWDOCUMENT=confirm.html
Upon receiving this command sequence the applet opens the page confirm.html page in a new window.
#SHOWERROR=Can't save the image file.
Upon receiving this command the applet displays the popup message:
The following table lists all the commands that the applet can process:
| Command | Applet's action |
|---|---|
| #SHOWDOCUMENT | The browser opens a new document. The parameter is the document's URL. The URL might be either absolute or relative to the saving script. |
| #SETDOCTAG | The parameter is the target frame for the document opened by #SHOWDOCUMENT command. This command must be sent before #SHOWDOCUMENT to have an effect. If this command is not specified the document pointed by #SHOWDOCUMENT replaces the current page. |
| #SHOWMESSAGE | The command parameter may be any text which is displayed in a popup dialog. |
| #SHOWERROR | The same as #SHOWMESSAGE but the dialog is error decorated. |
| #SHOWSTATUS | The parameter is displayed in the browser's status line. |
You may output any number of the commands but keep in mind that:
- each command must be placed on a separate line (i.e. separated by CRLF or LF characters)
- the commands are processed in the order they have been output.
See the example scripts: save.asp, save.aspx, save.php, save.jsp in the directories ASP, ASP.NET , PHP, JSP respectively.
Say you wish all the uploaded images to have a predefined size, for example 80x60. In that case specify the parameters:
<param name="scaleto" value="80,60">
<param name="proportion" value="8,6">
The parameter scaleto asks the applet to scale the image to the specified size. The scaling is performed just before the upload, invisibly for the user, and regardless of the current image size.
The parameter proportion constraints the image proportion during the processing. If it's specified the crop box keeps the specified proportion and the user can't upload images if their side ratio differ from the specified one. This constraint allows to avoid proportion distortions at final scaling.
It's also recommended to specify the minimal image size to avoid rough image pixalization while scaling. See the section The list of parameters for more details about the constraint parameters.
The applet can produce the image's thumbnail and upload it along with the master image. To obtain the thumbnail you have to specify a frame the thumbnail should be fitted in. For example:
<param name="thumbnail" value="40,30">
In that case the applet creates the image's thumbnail. It's width is less then or equal to 40 and height is less then or equal to 30. The upload request to the saving script looks as if it is issued by the following form:
<form method="post" action="save.php" enctype="multipart/form-data" >
<!-- master image fields -->
<input type="file" name="image">
<input type="text" name="width">
<input type="text" name="height">
<!-- thumbnail image fields -->
<input type="file" name="thumbnail">
<input type="text" name="thumbnail_width">
<input type="text" name="thumbnail_height">
<input type="submit">
</form>
Let's say you need to use an image file only once, for example to load the original use's file to the applet. After that those file is not required. In that case you may do the following:
Net Imaging can't process very big image files because applets are not provided with enough memory resources.
Typical image size maximum is about 3M pixels (for example
<param name="prescale" value="3M">
Some notes about performance:
The applet allows to print the displayed image. The print button is hidden by default.
Use the parameter visible_buttons to specify the print button explicitly.
Example:
<param name="visible_buttons" value="print,save,crop,undo,redo">
Note: The printing functionality is available with Java Plug-in only. Microsoft's Java (the native engine of IE) doesn't allow applets to print.
Using the applet parameters you can specify color and font for the labels and messages and the applet's background color. You can also specify what buttons are visible. Please read subsection Applet appearance in the section The list of parameters for details.
You can create several resource files and point the appropriate one depending on the current language context.
The button icons are kept in the applet's archive imaging.jar. To replace the icons with your own
do the following:
In addition to the parameters save and load the applet supports the following parameters:
Several national resource files have been prepared by Net Imaging users:
chinese.txt,
dutch.txt,
french.txt,
german.txt,
norwegian.txt,
russian.txt,
spanish.txt.
Custom icons for the buttons
Some useful notes:
The list of parameters
| parameter name | parameter values and their meaning | default |
|---|---|---|
| Upload control parameters | default | |
| jpeg_quality | Specifies quality of the resulting JPEG file. It's value can be any integer from 1 to 100. If this parameter is specified, the JPEG quality dialog doesn't appear. Thus the user is not able to control the JPEG quality while saving. |
defined by the user |
| filename | File name for the resulting image | image.jpg |
| blockunchanged | If the parameter is set the editor prevents the user from saving unchanged image. The parameter's value can be any text which is displayed while the user tries to save an unchaged image. | any image can be saved |
| scaleto | Asks the applet to scale the resulting image to a specific size. Example: The scaling is performed just before the upload and is invisible to the user. Since scaling is made regardless to the image proprotion it's recommended to use this parameter in conjunction with the parameter "proportion" which acts at the processing time and allows to avoid proportion distortions at final scaling. |
- |
| scale_method | Allows to specify a scaling method which is used for resize operations and thumbnail production.
The value can be one of the following: "default", "smooth", "averaging", "replicate". Example: |
the default (usually fastest) |
| thumbnail | Asks the applet to create image thumbnail and upload it along with the image itself.
The parameter's value must be width and height of the frame the thumbnail should fitted in. Example:
Along with the thumbnail the applet posts two values "thumbnail_width" and "thumbnail_height" which describe the actual size of the created the thumbnail. |
- |
| thumbfilename | File name for the image's thumbnail (if the thumbnail parameter is defined) | thumbnail.jpg |
| logo | URL of a small image file (GIF or JPEG) that you wish to apply to the users image.
The specified image is put at right-bottom corner of the user's image before the upload and print.
The URL can be specified as absolute or relative to the current HTML file.
Example: |
- |
| Image constraints parameters
If at least one of the following constraint parameters is specified the applet displays a special indicator that shows the user if the current image is proper; and if the user tries to upload an improper image the appropriate error message is displayed and the upload action is blocked. |
default | |
| proportion | Defines width:height proportion of the resulting image.
The value must be two integers separated by comma that specify a width:height ratio, for example:
if this parameter is specified the user is able to resize the crop tool however it's proportion is kept automatically. Caution: Because of integer-valued rounding it's impossible sometimes to keep the specified proportion strictly, In such cases the applet maintains the constraint approximately. To control degree of this approximation you can specify (optionally) the required proportion precision. For example: <param name="proportion" value=" 3,4, 0.03 "> The example specifies that the proprotion 3:4 must be kept no worse then 3%. If no precision is specifyed the default value 0.02 is used. |
- |
| minsize | Defines minimum size of the resulting image.
The value must contain width and height separated by comma, for example:
  If this parameter is specified the applet doesn't allow to save the resulting image if it's size is less then the specified one. |
- |
| maxsize | Defines maximum size of the resulting image.
The value must contain width and height separated by comma, for example:
  If this parameter is specified the applet doesn't allow to save the resulting image if it's size is greater then the specified one.   You may also specify the optional parameter value auto after the size, for example: In that case the applet doesn't warn the user about big image size but scales down the image automatically before the upload. |
- |
| Applet appearance | ||
| bgcolor | The applet's backgound color. Should be specified as #RRGGBB | #C0C0C0 |
| fgcolor | Color for labels, messages and outlines. Should be specified as #RRGGBB | #000000 |
| font | Font for labels and messages. Should be specified as where: FONTFACE must be one of the following: Serif, SansSerif, Monospaced, Dialog. STYLE must be one of the following: plain, bold, italic, bolditalic. SIZE must be a reasonable integer number. Example: <param name="font" value="Serif-bold-16"> |
|
| visible_buttons | Allows to specify what buttons are visible on the top panel.
The parameter may contain the following comma delimited words:
For example: <param name="visible_buttons" value="save,resize,crop,undo,redo"> The buttons are displayd in the order they are listed. To make a gap between buttons use two commas typed one after another, for example |
all the buttons are visible |
| outline | Allows to turn on/off outlines of the buttons, panels, and dialogs. Possible values are: true and false. | true |
| hidestatuspanel | Specifies to hide the status panel (containing the image size and constraint indicator). Possible values are: true and false. | false |
| zoom | Sets the initial image zoom. You can specify any positive integer value, or "0" to fit the image in the applet's window. | Fit in Window |
| select | Allows to display the selection rectangle at startup.
The parameter's permits three value formats:
|
- |
| prescale | Specifies to scale down big image files. The parameter value is image size in pixels that can be
opened without prescale. The value can also be specified in Mega pixels. For that set the suffix "M" after the value.
Example: See additional notes in the section How to process large images. |
- |
| resources | URL of the resource file. See Customization and localization for details. | resources.txt |
Net Imaging was tested with the following browsers: IE4.x, IE5.x, IE6, Netscape 4.7, 6.2, 7.2, Mozilla 1.6, Firefox 1.0. The tests were made for both native browser's JVM:s (if such exist) and the Sun's Java Plug-in (JRE 1.3, 1.4, 1.5). The following issues have been found:
After the Windows XP security update published at the April, 2006 the browsers IE6 and IE7 ask users to click twice on any active content on web pages (applets, Active-X objects, etc..) before allowing to interact with them. To resolve the issue please read this article: http://izhuk.com/docs/ie7fix.html
Regardless of the successful tests the Author is not responsible for correct applet operation on any particular hardware, software platform, and their configurations.
Copyright 2003 - 2008. Igor Zhukovsky www.izhuk.com