Skip to content

Commit

Permalink
Stop using option_link.cgi and link directly to the site.
Browse files Browse the repository at this point in the history
  • Loading branch information
dlemstra committed Jul 26, 2024
1 parent 2814d3d commit 9bf16fc
Show file tree
Hide file tree
Showing 54 changed files with 1,831 additions and 1,902 deletions.
24 changes: 12 additions & 12 deletions advanced/index.html

Large diffs are not rendered by default.

82 changes: 41 additions & 41 deletions anim_basics/index.html

Large diffs are not rendered by default.

84 changes: 42 additions & 42 deletions anim_mods/index.html

Large diffs are not rendered by default.

36 changes: 18 additions & 18 deletions anim_opt/index.html

Large diffs are not rendered by default.

62 changes: 31 additions & 31 deletions annotating/index.html

Large diffs are not rendered by default.

10 changes: 5 additions & 5 deletions antialiasing/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ <h2>Anti-Aliasing Introduction</h2></a> ImageMagick when it draws images, does s
</td>
</tr>
</table><a href="drawn.png"><img src="drawn.png" width="80" height="80" align="middle" vspace="5" hspace="5" border="0" alt="[IM Output]"></a> <img src="../img_www/right.gif" width="20" height="20" align="middle" alt="==&gt;"> <a href="drawn_mag.png"><img src="drawn_mag.png" width="80" height="80" align="middle" vspace="5" hspace="5" border="1" alt="[IM Output]"></a>
</div>Now you would think that the above image would have only three colors, 'white', 'black', and 'transparent', as that is all we asked for IM to use. But as you can see when the image is magnified it has a whole range of colors. By doing this ImageMagick makes the image look smoother and better looking, using a technique called 'anti-aliasing'. This is a fancy term that means it fills in edge pixels of the object with a mix of colors and even transparencies, to make the object look smoother. If no anti-aliasing was done, then the edges of all the draw objects would have a staircase like effect called 'aliasing' though more commonly referred to as the 'jaggies'. Here we draw the image again but this time we asked IM to turn off its automatic anti-aliasing operations, using "<code><a href="../option_link.cgi?antialias">+antialias</a></code>".
</div>Now you would think that the above image would have only three colors, 'white', 'black', and 'transparent', as that is all we asked for IM to use. But as you can see when the image is magnified it has a whole range of colors. By doing this ImageMagick makes the image look smoother and better looking, using a technique called 'anti-aliasing'. This is a fancy term that means it fills in edge pixels of the object with a mix of colors and even transparencies, to make the object look smoother. If no anti-aliasing was done, then the edges of all the draw objects would have a staircase like effect called 'aliasing' though more commonly referred to as the 'jaggies'. Here we draw the image again but this time we asked IM to turn off its automatic anti-aliasing operations, using "<code><a href="https://imagemagick.org/script/command-line-options.php?#antialias">+antialias</a></code>".
<div align="center">
<table class="table table-sm table-hover table-striped" cellspacing="0" cellpadding="5" width="90%" bgcolor="#F8F8F8">
<tr>
Expand Down Expand Up @@ -120,7 +120,7 @@ <h2>Drawing Thin Bitmapped Circles</h2>Here we look at trying to draw bitmaped '
<a href="circle_aliased.gif"><img src="circle_aliased.gif" align="middle" vspace="5" hspace="5" border="1" alt="[IM Output]"></a>
</td>
</tr>
</table>What you need to to is also adjust the "<code><a href="../option_link.cgi?strokewidth">-strokewidth</a></code>" , which defaults to 1 pixel wide, to something smaller, such as 0.5 pixels wide.
</table>What you need to to is also adjust the "<code><a href="https://imagemagick.org/script/command-line-options.php?#strokewidth">-strokewidth</a></code>" , which defaults to 1 pixel wide, to something smaller, such as 0.5 pixels wide.
<table border="0" cellspacing="0" cellpadding="0" width="100%" align="center">
<tr>
<td width="100%" align="justify">
Expand Down Expand Up @@ -180,7 +180,7 @@ <h2>Drawing Thin Bitmapped Circles</h2>Here we look at trying to draw bitmaped '
<a href="circle_perfect.gif"><img src="circle_perfect.gif" align="middle" vspace="5" hspace="5" border="1" alt="[IM Output]"></a>
</td>
</tr>
</table>However After many experiments I could find no "<code><a href="../option_link.cgi?strokewidth">-strokewidth</a></code>" that works for all radii and centers. Especally a circle that is slightly off center.
</table>However After many experiments I could find no "<code><a href="https://imagemagick.org/script/command-line-options.php?#strokewidth">-strokewidth</a></code>" that works for all radii and centers. Especally a circle that is slightly off center.
<div align="center">
<b>There is no ideal solution for all situations</b>
</div>For example this circle which is not centered on a pixel, or a pixel boundary, not only has gaps at the top, but is also too thick at the bottom! Yuck!
Expand All @@ -203,7 +203,7 @@ <h2>Drawing Thin Bitmapped Circles</h2>Here we look at trying to draw bitmaped '
<a href="circle_bad_stroke.gif"><img src="circle_bad_stroke.gif" align="middle" vspace="5" hspace="5" border="1" alt="[IM Output]"></a>
</td>
</tr>
</table>Here is a table of good "<code><a href="../option_link.cgi?strokewidth">-strokewidth</a></code>", to generate a thin single pixel wide circle of specific radius. Note that the best value to use varies depending on if the circle is centered either on an <i>actual</i> pixel (such as ' <code>5 , 5</code> '), or on a <i>half</i> pixel boundry (such as ' <code>5.5 , 5.5</code> ')
</table>Here is a table of good "<code><a href="https://imagemagick.org/script/command-line-options.php?#strokewidth">-strokewidth</a></code>", to generate a thin single pixel wide circle of specific radius. Note that the best value to use varies depending on if the circle is centered either on an <i>actual</i> pixel (such as ' <code>5 , 5</code> '), or on a <i>half</i> pixel boundry (such as ' <code>5.5 , 5.5</code> ')
<table class="table table-sm table-hover table-striped" width="50%" cellspacing="0" align="center">
<tr>
<th align="center">Circle Radius</th>
Expand Down Expand Up @@ -298,7 +298,7 @@ <h2>Drawing Thin Bitmapped Circles</h2>Here we look at trying to draw bitmaped '
<hr>
<!-- ---------------------------------------------------------------- -->
<a name="floodfill" id="floodfill">
<h2>Anti-Aliasing and Flood Fill Problems</h2></a> Due to anti-aliasing features of IM, flood-filling ("<code><a href="../option_link.cgi?threshold">-draw</a> color floodfill</code>") has problems when used on images with anti-aliasing effects. It also has similar problems with images read in from the "JPG" image format. Basically as most objects in IM are anti-aliased (or read from a "JPG" format image file), colors near the edges of drawn objects are rarely the specific color that you are using flood fill to replace. This means the flood fill will not fill the very edges of the areas you are trying to fill, unless you are avoiding anti-aliasing entirely. Essentially flood fill, or even color replace, does not understand anti-aliasing, nor does it use anti-aliasing techniques itself. Consequently flood fill will generally miss the pixels at the very edge of the area you are filling. For example, Here we do a typical flood fill operation. Draw a circle, then try to fill it with a pattern...
<h2>Anti-Aliasing and Flood Fill Problems</h2></a> Due to anti-aliasing features of IM, flood-filling ("<code><a href="https://imagemagick.org/script/command-line-options.php?#threshold">-draw</a> color floodfill</code>") has problems when used on images with anti-aliasing effects. It also has similar problems with images read in from the "JPG" image format. Basically as most objects in IM are anti-aliased (or read from a "JPG" format image file), colors near the edges of drawn objects are rarely the specific color that you are using flood fill to replace. This means the flood fill will not fill the very edges of the areas you are trying to fill, unless you are avoiding anti-aliasing entirely. Essentially flood fill, or even color replace, does not understand anti-aliasing, nor does it use anti-aliasing techniques itself. Consequently flood fill will generally miss the pixels at the very edge of the area you are filling. For example, Here we do a typical flood fill operation. Draw a circle, then try to fill it with a pattern...
<table border="0" cellspacing="0" cellpadding="0" width="100%" align="center">
<tr>
<td width="100%" align="justify">
Expand Down
8 changes: 4 additions & 4 deletions api/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -284,7 +284,7 @@ <h4>PHP Security</h4>Remember...
<li>Backslashes (directory seperators), and '<code>..</code>' paths, Also under windows '<code>\</code>' and '<code>;</code>' in filenames.</li>
<li>File Expansion Meta-characters including "<code>~*?[]{}&lt;&gt;</code>" plus the special "<code>@</code>" meta-character specific to ImageMagick.</li>
<li>Other shell meta-characters including "<code>$#;</code>" and the three quote character '<code>'</code>', '<code>"</code>', '<code>`</code>'</li>
<li>Argument does not match what ImageMagick expects. Use "<code><a href="../option_link.cgi?list">-list</a></code>" to read what types of argument IM does understand for specific options. For example an user input "<code><a href="../option_link.cgi?gravity">-gravity</a></code>" option, only has 10 different settings.</li>
<li>Argument does not match what ImageMagick expects. Use "<code><a href="https://imagemagick.org/script/command-line-options.php?#list">-list</a></code>" to read what types of argument IM does understand for specific options. For example an user input "<code><a href="https://imagemagick.org/script/command-line-options.php?#gravity">-gravity</a></code>" option, only has 10 different settings.</li>
<li>And so on...</li>
</ul>For any sort of web programming work, an understanding of security and how hackers can use specially crafted arguemnts to subvert called commands, is vital. Not just for PHP, but for Shell, and ImageMagick. IM requires particular care as it can for example read and magick a password file into an image to be returned. Again... It is far better to be overly restrictive, than open an unforseen security hole, when the web is involved.
<h4>Writing to the Filesystem</h4>As mentioned above, and if you followed the above initial proceedure, you will know for certain, PHP generally runs as a different. more resctritive user on the server. Because of this it will typicall NOT be able to write to the directory containing the script (or where ever it is actually running. For security reasons you generally <b>do not want to write to that directory</b>! If you really want PHP to write files, have it save the image (or data) to an unique filename in "<code>/tmp</code>", and above all <b>clean up afterward</b>, on both normal exit, or on ANY error. It is amazing how quickly you can fill a disk with left over temporary files from an application that does not cleanup properly. If the saved files (images) must be visible by the web server, make a special 'write by program' sub-directory, for those files. <b>How it should be done.</b> Most PHP applications actually avoid writing anything to the file system by using a database backend. That is, cookies, tokens, user data, images, and so on are all written into a database, such as (in order of complexity and scale) SQLite, PostgresSQL, MySQL, and Oracle. It saves nothing in the filesystem at all. System Programmers will typically configure the PHP application with that information when the application is installed. Images is typically reproduced by either the same, or separate PHP script that looks up the image 'blob' and outputs it to the client. Images may be sent as 'inline' images with the HTML itself (see, the "<code><a href="../files/#inline">inline:</a></code>" format, which has a demonstration of HTML inline images), or as a single 'all in one' multiple image, so the client HTML/JAVA only has one image reqest rather than 20 separate requests. One final point. Some method of cleaning up old data should always be present. An user that has not logged in for 2 year, probably should have his data deleted.
Expand Down Expand Up @@ -473,7 +473,7 @@ <h2>Hints for Better ImageMagick Shell/PHP Scripts</h2>These were some basic scr
</td>
</tr>
</table>
</div>Also note how I output the exact reason for the abort to the user, and specifically the special feature(s) the version check was for. Otherwise you may later forget why that specific version (or higher) was needed. You can also modify the behaviour of IM for specific versions. For example say I want to get a list of available fonts. Before IM version v6.3.5-7 the "<code><a href="../option_link.cgi?list">-list</a></code>" setting "<code>type</code>" returned the 'known font' list. With later versions, you need to use "<code>font</code>" setting instead. So here I can do a version check to use the right setting to get the information needed.
</div>Also note how I output the exact reason for the abort to the user, and specifically the special feature(s) the version check was for. Otherwise you may later forget why that specific version (or higher) was needed. You can also modify the behaviour of IM for specific versions. For example say I want to get a list of available fonts. Before IM version v6.3.5-7 the "<code><a href="https://imagemagick.org/script/command-line-options.php?#list">-list</a></code>" setting "<code>type</code>" returned the 'known font' list. With later versions, you need to use "<code>font</code>" setting instead. So here I can do a version check to use the right setting to get the information needed.
<div align="center">
<table class="table table-sm table-hover table-striped" cellspacing="0" cellpadding="5" width="90%" bgcolor="#F8F8F8">
<tr>
Expand Down Expand Up @@ -503,7 +503,7 @@ <h2>Hints for Better ImageMagick Shell/PHP Scripts</h2>These were some basic scr
</table>
</div>WARNING: The extra '<code>+</code>' in the above is normally not needed, at least for this test, but is needed if the variable could contain the special keyword '<code>match</code>" which would give "<code>expr</code>" problems, especially if it is being used for string or sub-string work.
</li>
<li>You can also make use of the "<code><a href="../option_link.cgi?list">-list</a></code>" information output to check if some special feature has been added to the currently installed ImageMagick.
<li>You can also make use of the "<code><a href="https://imagemagick.org/script/command-line-options.php?#list">-list</a></code>" information output to check if some special feature has been added to the currently installed ImageMagick.
<div align="center">
<table class="table table-sm table-hover table-striped" cellspacing="0" cellpadding="5" width="90%" bgcolor="#F8F8F8">
<tr>
Expand All @@ -519,7 +519,7 @@ <h2>Hints for Better ImageMagick Shell/PHP Scripts</h2>These were some basic scr
</td>
</tr>
</table>
</div>However be warned that often a new method, like "<code><a href="../option_link.cgi?distort">-distort</a> Arc</code>" could appear during IM development before it is properly ready for general use. As such a version check may still be the better idea. This is why in IM Examples I try to note (look for <img src="../img_www/warning.gif" width="28" height="28"> symbols) the IM version when a new feature have become stable enough for general use.
</div>However be warned that often a new method, like "<code><a href="https://imagemagick.org/script/command-line-options.php?#distort">-distort</a> Arc</code>" could appear during IM development before it is properly ready for general use. As such a version check may still be the better idea. This is why in IM Examples I try to note (look for <img src="../img_www/warning.gif" width="28" height="28"> symbols) the IM version when a new feature have become stable enough for general use.
</li>
<li>Don't use very very long single lines. Especially for complex 'convert' commands. Split them up using line-continuation methods (shown above), such as '<code>\</code>' in UNIX, '<code>^</code>' in DOS, and '<code>.</code>' string concatenation in PHP. However I do not mean placing each and EVERY setting and operation on a separate line. Do one major operation or stage per line, create new image, modify image, merge with other images, etc. Place all operational settings needed for a specific operator just before that operator. Think of each line as single processing step. This lets you separate the lines so as to allow for the easier reading, and understanding of individual processing steps. The clearer the separation of operators, the easier a complex image process is to follow. Using extra <a href="../basics/#parenthesis">parenthesis</a>, indenting the lines over various stages, or even add empty lines between large processing blocks, can make it even easier to see the major stages of large and long operation. I use these techniques all over IM examples, so as to make the examples easier to follow and understand, so just look around! Finally extra comments about what a specific command is doing can make a big difference in someone else (or even yourself 2 months later) reading and understanding your script. Shame you can not currently insert comments in a long command line!
</li>
Expand Down
Loading

0 comments on commit 9bf16fc

Please sign in to comment.