Forums before death by AOL, social media and spammers... "We can't have nice things"
|    comp.mobile.android    |    Discussion about Android-based devices    |    236,147 messages    |
[   << oldest   |   < older   |   list   |   newer >   |   newest >>   ]
|    Message 236,082 of 236,147    |
|    Maria Sophia to Maria Sophia    |
|    Re: PSA: Creating *any* RGB solid color     |
|    17 Feb 26 20:56:30    |
      XPost: misc.phone.mobile.iphone, alt.comp.os.windows-10       From: mariasophia@comprehension.com              Maria Sophia wrote:       > C:\> gvim wallpaper.ppm       > P3 400 100 255 171 205 239       > C:\> magick wallpaper.ppm wallpaper.png       > That creates a 400x100 pixel solid #ABCDEF PNG, identical to the       > downloaded image created from the single-color-image web site above.              Oops. I wrote that PSA off the cuff in a few minutes so I didn't realize       there was missing data in the description that was actually in my ppm file.        C:\> type wallpaper.ppm        P3 1 1 255 171 205 239        C:\> magick wallpaper.ppm wallpaper.png              That was my mistake. The prior PPM header declares 400x100 pixels       (40,000 pixels total), but only provides one pixel's worth of RGB       data. ImageMagick is stricter than Irfanview about PPM completeness.              The PPM I actually used when testing was:        P3 1 1 255 171 205 239       which is a complete 1x1 PPM. ImageMagick accepts that file because       it contains exactly the amount of pixel data the header declares.              P3 -> Magic number. Means "ASCII PPM" (Portable Pixmap, text format).       1 -> Image width in pixels. This file contains exactly 1 column.       1 -> Image height in pixels. This file contains exactly 1 row.       255 -> Maximum channel value. Defines the scale for R, G, B.        255 means each color channel ranges from 0 to 255.       171 -> Red channel value for the single pixel (0-255).        This corresponds to hex AB.       205 -> Green channel value for the single pixel (0-255).        This corresponds to hex CD.       239 -> Blue channel value for the single pixel (0-255).        This corresponds to hex EF.              IrfanView is more forgiving than ImageMagick. If a PPM ends early,       IrfanView simply repeats the last pixel to fill the image. That is       why my original example appeared to work in IrfanView but not in       ImageMagick and I accidentally didn't make that distinction prior.              Mea culpa!              The correct minimal PPM for a solid color is therefore:        P3 1 1 255 R G B       Then you can scale it to any size you want using any way you want.              For example:        C:\> magick wallpaper.ppm -scale 400x100! wallpaper.png               -scale -> Resize operation.        Tells ImageMagick to scale the image to a new size.        400x100! -> Target dimensions for the resize.        400 = width in pixels        100 = height in pixels        ! = force exact size, ignore aspect ratio.        (The bang means to stretch or squash if needed.)              This produces a mathematically perfect solid-color image of any       desired resolution such as these for my three platforms I own:              a. Windows (1920x1080)        C:\> magick wallpaper.ppm -scale 1920x1080! win-1920x1080.png              b. Android (Galaxy A32-5G, 1600x720)        C:\> magick wallpaper.ppm -scale 1600x720! android-1600x720.png              c. iOS (10th-gen iPad, 2360x1640)        C:\> magick wallpaper.ppm -scale 2360x1640! ipad-2360x1640.png              As always, these PSAs and Tutorials are written to help everyone.       If/when you find an error, please improve so that everyone benefits.       --       If we think we understand something, we don't. But if we think we don't       quite yet understand something, then we're just beginning to understand it.              --- SoupGate-Win32 v1.05        * Origin: you cannot sedate... all the things you hate (1:229/2)    |
[   << oldest   |   < older   |   list   |   newer >   |   newest >>   ]
(c) 1994, bbs@darkrealms.ca