"convert -level 20%,100%,0.5" doesn't preserve black
Posted: 2011-12-17T19:26:57-07:00
I found "convert -level 20%,100%,0.5" doesn't preserve black.
I made a simple PGM file which is gradation from black to white (using Ruby).
The leftest pixel is black (value 0) and the rightest pixel (value 255) is white.
"convert -level 20%,100%,0.5" converts the black pixel to a dark gray (value 16 = 020).
I guess it it not intentional behavior.
I tested ImageMagick-6.7.4 taken with svn.
I made a simple PGM file which is gradation from black to white (using Ruby).
The leftest pixel is black (value 0) and the rightest pixel (value 255) is white.
"convert -level 20%,100%,0.5" converts the black pixel to a dark gray (value 16 = 020).
I guess it it not intentional behavior.
I tested ImageMagick-6.7.4 taken with svn.
Code: Select all
% ruby -e 'STDOUT.binmode; print "P5\n256 1\n255\n", (0..255).to_a.pack("C*")' > src.pgm
% convert -level 20%,100%,0.5 src.pgm dst.pgm
% od -c src.pgm
0000000 P 5 \n 2 5 6 1 \n 2 5 5 \n \0 001 002
0000020 003 004 005 006 \a \b \t \n \v \f \r 016 017 020 021 022
0000040 023 024 025 026 027 030 031 032 033 034 035 036 037 ! "
0000060 # $ % & ' ( ) * + , - . / 0 1 2
0000100 3 4 5 6 7 8 9 : ; < = > ? @ A B
0000120 C D E F G H I J K L M N O P Q R
0000140 S T U V W X Y Z [ \ ] ^ _ ` a b
0000160 c d e f g h i j k l m n o p q r
0000200 s t u v w x y z { | } ~ 177 200 201 202
0000220 203 204 205 206 207 210 211 212 213 214 215 216 217 220 221 222
0000240 223 224 225 226 227 230 231 232 233 234 235 236 237 240 241 242
0000260 243 244 245 246 247 250 251 252 253 254 255 256 257 260 261 262
0000300 263 264 265 266 267 270 271 272 273 274 275 276 277 300 301 302
0000320 303 304 305 306 307 310 311 312 313 314 315 316 317 320 321 322
0000340 323 324 325 326 327 330 331 332 333 334 335 336 337 340 341 342
0000360 343 344 345 346 347 350 351 352 353 354 355 356 357 360 361 362
0000400 363 364 365 366 367 370 371 372 373 374 375 376 377
0000415
% od -c dst.pgm
0000000 P 5 \n 2 5 6 1 \n 2 5 5 \n 020 017 017
0000020 016 016 \r \f \f \v \v \n \n \t \t \b \b \b \a \a
0000040 006 006 006 005 005 004 004 004 004 003 003 003 002 002 002 002
0000060 002 001 001 001 001 001 001 \0 \0 \0 \0 \0 \0 \0 \0 \0
0000100 \0 \0 \0 \0 \0 \0 \0 \0 \0 \0 001 001 001 001 001 001
0000120 002 002 002 002 002 003 003 003 004 004 004 004 005 005 006 006
0000140 006 \a \a \b \b \b \t \t \n \n \v \v \f \f \r 016
0000160 016 017 017 020 021 021 022 023 023 024 025 025 026 027 030 030
0000200 031 032 033 034 034 035 036 037 ! " " # $ % &
0000220 ' ( ) * + , - . / 1 2 3 4 5 6 7
0000240 8 : ; < = ? @ A B D E F G I J K
0000260 M N P Q R T U W X Z [ ] ^ ` a c
0000300 d f h i k l n p q s u v x z | }
0000320 177 201 203 204 206 210 212 214 216 217 221 223 225 227 231 233
0000340 235 237 241 243 245 247 251 253 255 257 261 263 265 267 272 274
0000360 276 300 302 304 307 311 313 315 317 322 324 326 331 333 335 340
0000400 342 344 347 351 353 356 360 363 365 370 372 375 377
0000415