Plugin Directory

Changeset 930342


Ignore:
Timestamp:
06/11/2014 12:29:17 PM (11 years ago)
Author:
HansVanEijsden
Message:

Fixed the ACL checkbox bug

Location:
imagemagick-sharpen-resized-images
Files:
4 edited
1 copied

Legend:

Unmodified
Added
Removed
  • imagemagick-sharpen-resized-images/tags/1.1.3/imagick-sharpen-resized-images.php

    r927867 r930342  
    11<?php
     2
    23/*
     4
    35Plugin Name: ImageMagick Sharpen Resized Images
     6
    47Plugin URI: http://www.hansvaneijsden.com/wordpress-sharpen-resized-images-plugin/
     8
    59Description: Improve your images: Sharpens resized JPG image uploads via ImageMagick so it keeps quality, EXIF information, color profiles and crops.
     10
    611Author: Hans van Eijsden
     12
    713Author URI: http://www.hansvaneijsden.com/
    8 Version: 1.1.2
     14
     15Version: 1.1.3
     16
    917License: GPL v3
    1018
     19
     20
    1121This program is free software: you can redistribute it and/or modify
     22
    1223it under the terms of the GNU General Public License as published by
     24
    1325the Free Software Foundation, either version 3 of the License, or
     26
    1427(at your option) any later version.
    1528
     29
     30
    1631This program is distributed in the hope that it will be useful,
     32
    1733but WITHOUT ANY WARRANTY; without even the implied warranty of
     34
    1835MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
     36
    1937GNU General Public License for more details.
    2038
     39
     40
    2141You should have received a copy of the GNU General Public License
     42
    2243along with this program.  If not, see <http://www.gnu.org/licenses/>.
     44
    2345*/
     46
    2447function imagick_sharpen_resized_files_register_settings() {
     48
    2549    add_option('Radius','0');
     50
    2651    add_option('Sigma','0.5');
     52
    2753    add_option('Sharpening','1');
     54
    2855    add_option('Threshold','0');
     56
    2957    add_option('CompressionQuality','92');
    30     add_option('AutoConLev',true);
     58
     59    add_option('AutoConLev',1);
     60
    3161    register_setting('imagick_sharpen_resized_files_settings','Radius');
     62
    3263    register_setting('imagick_sharpen_resized_files_settings','Sigma');
     64
    3365    register_setting('imagick_sharpen_resized_files_settings','Sharpening');
     66
    3467    register_setting('imagick_sharpen_resized_files_settings','Threshold');
    35     register_setting('imagick_sharpen_resized_files_settings','AutoConLev');
     68
     69    register_setting('imagick_sharpen_resized_files_settings','AutoConLev','save_ACL');
     70
    3671    register_setting('imagick_sharpen_resized_files_settings','CompressionQuality');
    3772
     73
     74
    3875}
    3976
     77
     78
    4079function imagick_sharpen_resized_files_register_options_page() {
     80
    4181    add_options_page('ImageMagick Sharpen Resized Images','IM Sharpen Images','manage_options',__FILE__,'imagick_sharpen_resized_files_options_page');
     82
    4283}
    4384
    44  
     85
     86
     87function save_ACL ( $input ) {
     88
     89    $option = get_option('AutoConLev');
     90
     91    if ( ! isset( $input ) || $input != 1 ) {
     92
     93        $option = 0;
     94
     95    } else {
     96
     97        $option = 1;
     98
     99    }
     100
     101    return $option;
     102
     103}
     104
     105
    45106
    46107function imagick_sharpen_resized_files_deactivate(){
     108
    47109   //delete plugins option here ex:
     110
    48111  delete_option('Radius');
     112
    49113  delete_option('Sigma');
     114
    50115  delete_option('Sharpening');
     116
    51117  delete_option('Threshold');
     118
    52119  delete_option('CompressionQuality');
     120
    53121  delete_option('AutoConLev');
     122
    54123}
    55124
     125
     126
    56127function imagick_sharpen_resized_files_options_page() {     // Output the options page
     128
    57129?>
     130
    58131    <div class="wrap">
     132
    59133    <h2>ImageMagick Sharpen Resized Images</h2>
     134
    60135    <p><a href="http://www.hansvaneijsden.com/wordpress-sharpen-resized-images-plugin/"><?php _e('Plugin Home Page'); ?></a> |
     136
    61137    <a href="http://wordpress.org/plugins/imagemagick-sharpen-resized-images/"><?php _e('WordPress Plugin Page'); ?></a></p>
    62138
     139
     140
    63141<p>
     142
    64143<?php
     144
    65145        if (extension_loaded('imagick') || class_exists('Imagick'))
     146
    66147{
     148
    67149    // imagick PHP module is installed
     150
    68151echo 'ImageMagick PHP Module: <span style="color: green; font-weight: bolder">OK, installed';
     152
    69153        } else {
     154
    70155echo 'ImageMagick PHP Module: <span style="color: red; font-weight: bolder">MISSING, not installed';
     156
    71157        }
     158
    72159?>
     160
    73161</p>
     162
    74163<p>The default settings are great, but you can adjust them to your taste here: </p>
    75164
     165
     166
    76167    <form method="post" action="options.php">
     168
    77169        <?php settings_fields('imagick_sharpen_resized_files_settings'); ?>
     170
    78171        <?php do_settings_sections('imagick_sharpen_resized_files_settings'); ?>
     172
    79173        <table class="form-table">
    80             <tr valign="top">
     174
     175            <tr valign="top">
     176
    81177            <th scope="row">Radius (0 = auto):</th>
     178
    82179            <td><input type="text" name="Radius" value="<?php echo get_option('Radius'); ?>" /></td>
    83             </tr>
     180
     181            </tr>
     182
    84183             
    85             <tr valign="top">
     184
     185            <tr valign="top">
     186
    86187            <th scope="row">Sigma:</th>
     188
    87189            <td><input type="text" name="Sigma" value="<?php echo get_option('Sigma'); ?>" /></td>
    88             </tr>
     190
     191            </tr>
     192
    89193           
    90             <tr valign="top">
     194
     195            <tr valign="top">
     196
    91197            <th scope="row">Amount Of Sharpening:</th>
     198
    92199            <td><input type="text" name="Sharpening" value="<?php echo get_option('Sharpening'); ?>" /></td>
    93             </tr>
    94 
    95             <tr valign="top">
     200
     201            </tr>
     202
     203
     204
     205            <tr valign="top">
     206
    96207            <th scope="row">Threshold:</th>
     208
    97209            <td><input type="text" name="Threshold" value="<?php echo get_option('Threshold'); ?>" /></td>
    98             </tr>
    99 
    100             <tr valign="top">
     210
     211            </tr>
     212
     213
     214
     215            <tr valign="top">
     216
    101217            <th scope="row">Compression Quality:</th>
     218
    102219            <td><input type="text" name="CompressionQuality" value="<?php echo get_option('CompressionQuality'); ?>" /></td>
    103             </tr>
    104 
    105 
    106             <tr valign="top">
     220
     221            </tr>
     222
     223
     224
     225
     226
     227            <tr valign="top">
     228
    107229            <th scope="row">Automatic Contrast Leveling:</th>
    108             <td><input type="checkbox" <?php if (get_option('AutoConLev')==true) echo 'checked="checked" '; ?> name="AutoConLev" value="<?php echo get_option('AutoConLev'); ?>" /></td>
    109             </tr>
     230
     231            <td><input type="checkbox" <?php if (get_option('AutoConLev')==1){ echo 'checked="checked" value="0"';  } else {echo 'value="1"';} ?> name="AutoConLev"  /></td>
     232
     233            </tr>
     234
    110235        </table>
     236
    111237       
     238
    112239        <?php submit_button(); ?>
     240
    113241    </form>
     242
    114243    </div>
    115244
     245
     246
    116247    <div id="fb-root"></div>
     248
    117249    <script>(function(d, s, id) {
     250
    118251        var js, fjs = d.getElementsByTagName(s)[0];
     252
    119253        if (d.getElementById(id)) return;
     254
    120255        js = d.createElement(s); js.id = id;
     256
    121257        js.src = "//connect.facebook.net/nl_NL/sdk.js#xfbml=1&appId=407436179311287&version=v2.0";
     258
    122259        fjs.parentNode.insertBefore(js, fjs);
     260
    123261        }(document, 'script', 'facebook-jssdk'));</script>
     262
    124263    <div class="fb-like-box" data-href="https://www.facebook.com/hansvaneijsdenphotography" data-colorscheme="light" data-show-faces="false" data-header="false" data-stream="false" data-show-border="false"></div>
     264
    125265<br>
     266
    126267    <a href="https://twitter.com/HansVanEijsden" class="twitter-follow-button" data-show-count="false" data-size="large">Follow @HansVanEijsden</a>
     268
    127269    <script>!function(d,s,id){var js,fjs=d.getElementsByTagName(s)[0],p=/^http:/.test(d.location)?'http':'https';if(!d.getElementById(id)){js=d.createElement(s);js.id=id;js.src=p+'://platform.twitter.com/widgets.js';fjs.parentNode.insertBefore(js,fjs);}}(document, 'script', 'twitter-wjs');</script>
    128270
     271
     272
    129273    <?php
     274
    130275}
    131276
     277
     278
    132279function imagick_sharpen_resized_files($resized_file) {
     280
    133281    $image = new Imagick($resized_file);
     282
    134283    $size = @getimagesize($resized_file);
     284
    135285    if (!$size)
     286
    136287        return new WP_Error('invalid_image', __('Could not read image size.'), $file);
     288
    137289    list($orig_w,$orig_h,$orig_type) = $size;
    138290
     291
     292
    139293    // We only want to use our sharpening on JPG files
     294
    140295    switch($orig_type) {
     296
    141297        case IMAGETYPE_JPEG:
    142298
     299
     300
    143301    // Automatic Contrast Leveling
     302
    144303    if (get_option('AutoConLev')==true) {
     304
    145305        $image->normalizeImage();
     306
    146307    }
    147308
     309
     310
    148311    // Sharpen the image (the default is via the Lanczos algorithm)
     312
    149313        $image->unsharpMaskImage(get_option('Radius'),get_option('Sigma'),get_option('Sharpening'),get_option('Threshold'));
     314
    150315       
     316
    151317    // Store the JPG file, with as default a compression quality of 92 (default WordPress = 90, default ImageMagick = 85...)
     318
    152319        $image->setImageFormat("jpg");
     320
    153321        $image->setImageCompression(Imagick::COMPRESSION_JPEG);
     322
    154323        $image->setImageCompressionQuality(get_option('CompressionQuality'));
     324
    155325        $image->writeImage($resized_file);
     326
    156327           
     328
    157329            break;
     330
    158331        default:
     332
    159333            return $resized_file;
     334
    160335    }   
     336
    161337   
     338
    162339    // Remove the JPG from memory
     340
    163341    $image->destroy();
     342
    164343   
     344
    165345    return $resized_file;
     346
    166347}   
     348
    167349   
     350
    168351add_filter('image_make_intermediate_size','imagick_sharpen_resized_files',900);
     352
    169353register_deactivation_hook( __FILE__,'imagick_sharpen_resized_files_deactivate');
     354
    170355add_action('admin_init','imagick_sharpen_resized_files_register_settings');
     356
    171357add_action('admin_menu','imagick_sharpen_resized_files_register_options_page');
     358
  • imagemagick-sharpen-resized-images/tags/1.1.3/readme.txt

    r927867 r930342  
    66Requires at least: 3.5
    77Tested up to: 3.9.1
    8 Stable tag: 1.1.2
     8Stable tag: 1.1.3
    99License: GPL v3
    1010License URI: http://www.gnu.org/licenses/gpl-3.0.html
     
    2222== Installation ==
    2323
    24 1. Upload `imagick-sharpen-resized-images.php` to the `/wp-content/plugins/` directory
     241. Upload `imagick-sharpen-resized-images.php` to the `/wp-content/plugins/` directory.
    25252. Activate the plugin through the 'Plugins' menu in WordPress.
    26263. In your Wordpress Settings you'll have a new admin entry: IM Sharpen Images.
     
    3232= Are there any system requirements? =
    3333
    34 Your host needs to have the [imagick PHP module](http://pecl.php.net/package/imagick) installed.
    35 The plugin has a built-in check.
     34Your host needs to have the [imagick PHP module](http://pecl.php.net/package/imagick) installed (and, of course, the [ImageMagick](http://www.imagemagick.org) program itself).
     35The imagick PHP module is NOT a WordPress plugin, but a module for PHP. The plugin has a built-in check for this imagick PHP module.
    3636
    37 If you don't have the PHP imagick module installed you can still sharpen your images by using the [Sharpen Resized Images](https://wordpress.org/plugins/sharpen-resized-images/) plugin. It sharpens the images by using lower quality GD, so it strips EXIF data and it strips color profiles.
     37If you don't have the imagick PHP module installed you can still sharpen your images by using the [Sharpen Resized Images](https://wordpress.org/plugins/sharpen-resized-images/) plugin. It sharpens the images by using lower quality GD, so it strips EXIF data and it strips color profiles.
    3838
    3939= I don't see any sharpening, why? =
    4040
    4141* After you enable the plugin it will only sharpen new uploads. If you want to sharpen your already uploaded images you will also need the [Regenerate Thumbnails](http://wordpress.org/plugins/regenerate-thumbnails/) plugin.
     42* Make sure to have not only the PHP module but also the ImageMagick software installed on the server (most servers have it though).
    4243* Still no differences? Clear your browser cache.
    4344* If you're using Varnish cache or other server caches, empty them.
     
    5960
    6061== Changelog ==
     62
     63= 1.1.3 =
     64* The Automatic Contrast Leveling checkbox bug has been fixed (thanks niwreg!)
    6165
    6266= 1.1.2 =
     
    8791
    8892= 1.0 =
    89 This fixes the WordPress blurry images problem
    90 
    91 == ToDo ==
    92 There's one thing I really want to fix: after unchecking the Automatic Contrast Leveling in Settings, it won't turn on again. Plugin needs deactivating and (re)activating to enable it again.
     93This fixes the WordPress blurry images problem.
  • imagemagick-sharpen-resized-images/trunk/imagick-sharpen-resized-images.php

    r927867 r930342  
    11<?php
     2
    23/*
     4
    35Plugin Name: ImageMagick Sharpen Resized Images
     6
    47Plugin URI: http://www.hansvaneijsden.com/wordpress-sharpen-resized-images-plugin/
     8
    59Description: Improve your images: Sharpens resized JPG image uploads via ImageMagick so it keeps quality, EXIF information, color profiles and crops.
     10
    611Author: Hans van Eijsden
     12
    713Author URI: http://www.hansvaneijsden.com/
    8 Version: 1.1.2
     14
     15Version: 1.1.3
     16
    917License: GPL v3
    1018
     19
     20
    1121This program is free software: you can redistribute it and/or modify
     22
    1223it under the terms of the GNU General Public License as published by
     24
    1325the Free Software Foundation, either version 3 of the License, or
     26
    1427(at your option) any later version.
    1528
     29
     30
    1631This program is distributed in the hope that it will be useful,
     32
    1733but WITHOUT ANY WARRANTY; without even the implied warranty of
     34
    1835MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
     36
    1937GNU General Public License for more details.
    2038
     39
     40
    2141You should have received a copy of the GNU General Public License
     42
    2243along with this program.  If not, see <http://www.gnu.org/licenses/>.
     44
    2345*/
     46
    2447function imagick_sharpen_resized_files_register_settings() {
     48
    2549    add_option('Radius','0');
     50
    2651    add_option('Sigma','0.5');
     52
    2753    add_option('Sharpening','1');
     54
    2855    add_option('Threshold','0');
     56
    2957    add_option('CompressionQuality','92');
    30     add_option('AutoConLev',true);
     58
     59    add_option('AutoConLev',1);
     60
    3161    register_setting('imagick_sharpen_resized_files_settings','Radius');
     62
    3263    register_setting('imagick_sharpen_resized_files_settings','Sigma');
     64
    3365    register_setting('imagick_sharpen_resized_files_settings','Sharpening');
     66
    3467    register_setting('imagick_sharpen_resized_files_settings','Threshold');
    35     register_setting('imagick_sharpen_resized_files_settings','AutoConLev');
     68
     69    register_setting('imagick_sharpen_resized_files_settings','AutoConLev','save_ACL');
     70
    3671    register_setting('imagick_sharpen_resized_files_settings','CompressionQuality');
    3772
     73
     74
    3875}
    3976
     77
     78
    4079function imagick_sharpen_resized_files_register_options_page() {
     80
    4181    add_options_page('ImageMagick Sharpen Resized Images','IM Sharpen Images','manage_options',__FILE__,'imagick_sharpen_resized_files_options_page');
     82
    4283}
    4384
    44  
     85
     86
     87function save_ACL ( $input ) {
     88
     89    $option = get_option('AutoConLev');
     90
     91    if ( ! isset( $input ) || $input != 1 ) {
     92
     93        $option = 0;
     94
     95    } else {
     96
     97        $option = 1;
     98
     99    }
     100
     101    return $option;
     102
     103}
     104
     105
    45106
    46107function imagick_sharpen_resized_files_deactivate(){
     108
    47109   //delete plugins option here ex:
     110
    48111  delete_option('Radius');
     112
    49113  delete_option('Sigma');
     114
    50115  delete_option('Sharpening');
     116
    51117  delete_option('Threshold');
     118
    52119  delete_option('CompressionQuality');
     120
    53121  delete_option('AutoConLev');
     122
    54123}
    55124
     125
     126
    56127function imagick_sharpen_resized_files_options_page() {     // Output the options page
     128
    57129?>
     130
    58131    <div class="wrap">
     132
    59133    <h2>ImageMagick Sharpen Resized Images</h2>
     134
    60135    <p><a href="http://www.hansvaneijsden.com/wordpress-sharpen-resized-images-plugin/"><?php _e('Plugin Home Page'); ?></a> |
     136
    61137    <a href="http://wordpress.org/plugins/imagemagick-sharpen-resized-images/"><?php _e('WordPress Plugin Page'); ?></a></p>
    62138
     139
     140
    63141<p>
     142
    64143<?php
     144
    65145        if (extension_loaded('imagick') || class_exists('Imagick'))
     146
    66147{
     148
    67149    // imagick PHP module is installed
     150
    68151echo 'ImageMagick PHP Module: <span style="color: green; font-weight: bolder">OK, installed';
     152
    69153        } else {
     154
    70155echo 'ImageMagick PHP Module: <span style="color: red; font-weight: bolder">MISSING, not installed';
     156
    71157        }
     158
    72159?>
     160
    73161</p>
     162
    74163<p>The default settings are great, but you can adjust them to your taste here: </p>
    75164
     165
     166
    76167    <form method="post" action="options.php">
     168
    77169        <?php settings_fields('imagick_sharpen_resized_files_settings'); ?>
     170
    78171        <?php do_settings_sections('imagick_sharpen_resized_files_settings'); ?>
     172
    79173        <table class="form-table">
    80             <tr valign="top">
     174
     175            <tr valign="top">
     176
    81177            <th scope="row">Radius (0 = auto):</th>
     178
    82179            <td><input type="text" name="Radius" value="<?php echo get_option('Radius'); ?>" /></td>
    83             </tr>
     180
     181            </tr>
     182
    84183             
    85             <tr valign="top">
     184
     185            <tr valign="top">
     186
    86187            <th scope="row">Sigma:</th>
     188
    87189            <td><input type="text" name="Sigma" value="<?php echo get_option('Sigma'); ?>" /></td>
    88             </tr>
     190
     191            </tr>
     192
    89193           
    90             <tr valign="top">
     194
     195            <tr valign="top">
     196
    91197            <th scope="row">Amount Of Sharpening:</th>
     198
    92199            <td><input type="text" name="Sharpening" value="<?php echo get_option('Sharpening'); ?>" /></td>
    93             </tr>
    94 
    95             <tr valign="top">
     200
     201            </tr>
     202
     203
     204
     205            <tr valign="top">
     206
    96207            <th scope="row">Threshold:</th>
     208
    97209            <td><input type="text" name="Threshold" value="<?php echo get_option('Threshold'); ?>" /></td>
    98             </tr>
    99 
    100             <tr valign="top">
     210
     211            </tr>
     212
     213
     214
     215            <tr valign="top">
     216
    101217            <th scope="row">Compression Quality:</th>
     218
    102219            <td><input type="text" name="CompressionQuality" value="<?php echo get_option('CompressionQuality'); ?>" /></td>
    103             </tr>
    104 
    105 
    106             <tr valign="top">
     220
     221            </tr>
     222
     223
     224
     225
     226
     227            <tr valign="top">
     228
    107229            <th scope="row">Automatic Contrast Leveling:</th>
    108             <td><input type="checkbox" <?php if (get_option('AutoConLev')==true) echo 'checked="checked" '; ?> name="AutoConLev" value="<?php echo get_option('AutoConLev'); ?>" /></td>
    109             </tr>
     230
     231            <td><input type="checkbox" <?php if (get_option('AutoConLev')==1){ echo 'checked="checked" value="0"';  } else {echo 'value="1"';} ?> name="AutoConLev"  /></td>
     232
     233            </tr>
     234
    110235        </table>
     236
    111237       
     238
    112239        <?php submit_button(); ?>
     240
    113241    </form>
     242
    114243    </div>
    115244
     245
     246
    116247    <div id="fb-root"></div>
     248
    117249    <script>(function(d, s, id) {
     250
    118251        var js, fjs = d.getElementsByTagName(s)[0];
     252
    119253        if (d.getElementById(id)) return;
     254
    120255        js = d.createElement(s); js.id = id;
     256
    121257        js.src = "//connect.facebook.net/nl_NL/sdk.js#xfbml=1&appId=407436179311287&version=v2.0";
     258
    122259        fjs.parentNode.insertBefore(js, fjs);
     260
    123261        }(document, 'script', 'facebook-jssdk'));</script>
     262
    124263    <div class="fb-like-box" data-href="https://www.facebook.com/hansvaneijsdenphotography" data-colorscheme="light" data-show-faces="false" data-header="false" data-stream="false" data-show-border="false"></div>
     264
    125265<br>
     266
    126267    <a href="https://twitter.com/HansVanEijsden" class="twitter-follow-button" data-show-count="false" data-size="large">Follow @HansVanEijsden</a>
     268
    127269    <script>!function(d,s,id){var js,fjs=d.getElementsByTagName(s)[0],p=/^http:/.test(d.location)?'http':'https';if(!d.getElementById(id)){js=d.createElement(s);js.id=id;js.src=p+'://platform.twitter.com/widgets.js';fjs.parentNode.insertBefore(js,fjs);}}(document, 'script', 'twitter-wjs');</script>
    128270
     271
     272
    129273    <?php
     274
    130275}
    131276
     277
     278
    132279function imagick_sharpen_resized_files($resized_file) {
     280
    133281    $image = new Imagick($resized_file);
     282
    134283    $size = @getimagesize($resized_file);
     284
    135285    if (!$size)
     286
    136287        return new WP_Error('invalid_image', __('Could not read image size.'), $file);
     288
    137289    list($orig_w,$orig_h,$orig_type) = $size;
    138290
     291
     292
    139293    // We only want to use our sharpening on JPG files
     294
    140295    switch($orig_type) {
     296
    141297        case IMAGETYPE_JPEG:
    142298
     299
     300
    143301    // Automatic Contrast Leveling
     302
    144303    if (get_option('AutoConLev')==true) {
     304
    145305        $image->normalizeImage();
     306
    146307    }
    147308
     309
     310
    148311    // Sharpen the image (the default is via the Lanczos algorithm)
     312
    149313        $image->unsharpMaskImage(get_option('Radius'),get_option('Sigma'),get_option('Sharpening'),get_option('Threshold'));
     314
    150315       
     316
    151317    // Store the JPG file, with as default a compression quality of 92 (default WordPress = 90, default ImageMagick = 85...)
     318
    152319        $image->setImageFormat("jpg");
     320
    153321        $image->setImageCompression(Imagick::COMPRESSION_JPEG);
     322
    154323        $image->setImageCompressionQuality(get_option('CompressionQuality'));
     324
    155325        $image->writeImage($resized_file);
     326
    156327           
     328
    157329            break;
     330
    158331        default:
     332
    159333            return $resized_file;
     334
    160335    }   
     336
    161337   
     338
    162339    // Remove the JPG from memory
     340
    163341    $image->destroy();
     342
    164343   
     344
    165345    return $resized_file;
     346
    166347}   
     348
    167349   
     350
    168351add_filter('image_make_intermediate_size','imagick_sharpen_resized_files',900);
     352
    169353register_deactivation_hook( __FILE__,'imagick_sharpen_resized_files_deactivate');
     354
    170355add_action('admin_init','imagick_sharpen_resized_files_register_settings');
     356
    171357add_action('admin_menu','imagick_sharpen_resized_files_register_options_page');
     358
  • imagemagick-sharpen-resized-images/trunk/readme.txt

    r927867 r930342  
    66Requires at least: 3.5
    77Tested up to: 3.9.1
    8 Stable tag: 1.1.2
     8Stable tag: 1.1.3
    99License: GPL v3
    1010License URI: http://www.gnu.org/licenses/gpl-3.0.html
     
    2222== Installation ==
    2323
    24 1. Upload `imagick-sharpen-resized-images.php` to the `/wp-content/plugins/` directory
     241. Upload `imagick-sharpen-resized-images.php` to the `/wp-content/plugins/` directory.
    25252. Activate the plugin through the 'Plugins' menu in WordPress.
    26263. In your Wordpress Settings you'll have a new admin entry: IM Sharpen Images.
     
    3232= Are there any system requirements? =
    3333
    34 Your host needs to have the [imagick PHP module](http://pecl.php.net/package/imagick) installed.
    35 The plugin has a built-in check.
     34Your host needs to have the [imagick PHP module](http://pecl.php.net/package/imagick) installed (and, of course, the [ImageMagick](http://www.imagemagick.org) program itself).
     35The imagick PHP module is NOT a WordPress plugin, but a module for PHP. The plugin has a built-in check for this imagick PHP module.
    3636
    37 If you don't have the PHP imagick module installed you can still sharpen your images by using the [Sharpen Resized Images](https://wordpress.org/plugins/sharpen-resized-images/) plugin. It sharpens the images by using lower quality GD, so it strips EXIF data and it strips color profiles.
     37If you don't have the imagick PHP module installed you can still sharpen your images by using the [Sharpen Resized Images](https://wordpress.org/plugins/sharpen-resized-images/) plugin. It sharpens the images by using lower quality GD, so it strips EXIF data and it strips color profiles.
    3838
    3939= I don't see any sharpening, why? =
    4040
    4141* After you enable the plugin it will only sharpen new uploads. If you want to sharpen your already uploaded images you will also need the [Regenerate Thumbnails](http://wordpress.org/plugins/regenerate-thumbnails/) plugin.
     42* Make sure to have not only the PHP module but also the ImageMagick software installed on the server (most servers have it though).
    4243* Still no differences? Clear your browser cache.
    4344* If you're using Varnish cache or other server caches, empty them.
     
    5960
    6061== Changelog ==
     62
     63= 1.1.3 =
     64* The Automatic Contrast Leveling checkbox bug has been fixed (thanks niwreg!)
    6165
    6266= 1.1.2 =
     
    8791
    8892= 1.0 =
    89 This fixes the WordPress blurry images problem
    90 
    91 == ToDo ==
    92 There's one thing I really want to fix: after unchecking the Automatic Contrast Leveling in Settings, it won't turn on again. Plugin needs deactivating and (re)activating to enable it again.
     93This fixes the WordPress blurry images problem.
Note: See TracChangeset for help on using the changeset viewer.