Simple patch for makepkg: Optimize PNG/JPEG images losslessly

Hello there! I've written a (rather simple) patch for Makepkg that makes use of the tools jpegoptim and optipng, using more or less the same method that the current code for using UPX works.
These two utilities use a handful of methods for producing more efficiently optimized image files, while not losing or altering the image given by decompression.
47c47
< packaging_options=('strip' 'docs' 'libtool' 'emptydirs' 'zipman' 'purge' 'upx')
> packaging_options=('strip' 'docs' 'libtool' 'emptydirs' 'zipman' 'purge' 'upx' 'img')
1055c1055
< find . -type f -perm -u+w 2>/dev/null | while read binary ; do
> find . -type f -iname "*.png" 2>/dev/null | while read binary ; do
1061a1062,1075
> if [[ $(check_option img) = "y" ]]; then
> msg2 "$(gettext "Compressing images...")"
> local image
> find . -type f 2>/dev/null | while read image ; do
> if [[ $(file -bi "$image") = *'image/png'* ]]; then
> optipng "$image" &>/dev/null ||
> warning "$(gettext "Could not compress image : %s")" "${image/$pkgdir\//}"
> fi
> if [[ $(file -bi "$image") = *'image/jpeg'* ]]; then
> jpegoptim "$image" &>/dev/null ||
> warning "$(gettext "Could not compress image : %s")" "${image/$pkgdir\//}"
> fi
> done
> fi
1647a1662,1669
> ret=1
> fi
> fi
>
> # img - image compression
> if [[ $(check_option img) == 'y' ]]; then
> if ! type -p jpegoptim >/dev/null; then
> error "$(gettext "Cannot find the %s binary required for compressing images.")" "jpegoptim"
Save as makepkg.patch, patch /usr/bin/makepkg makepkg.patch, then add 'img' to your OPTIONS in /etc/makepkg.conf.
On most files this gives a 5-10% space optimization, but with smaller files or files which were badly compressed in the first place it can get 30-50%.
Obviously some things could be more elegant, there's no method given here to pass options to either program, but implementing that would be trivial.
Anyone interested?

You should ask about this on the [pacman-dev] mailing list.  It is nice that you are sharing it here.  But if you really think this is a superior way of handling it, then submitting it upstream for review is probably the better thing to do.

Similar Messages

  • Kernel26 PKGBUILD: A simple patch for customization

    Hi all!
    I have saw many PKGBUILDs for custom kernels. There is some on the wiki, some on the forum, others on AUR, etc. Diversity is great, as the possible choices, but it gets a bit confusing because each of these PKGBUILDs are different. It's a bit like to many forks of a project...
    I sometimes want a customized kernel, but since I'm not a kernel dev/maintainer, I still want to keep the -ARCH kernel. If I break something in my own customization, I still want to be able to boot. I think others will want the same thing.
    What I propose is a modification the stock PKGBUILD so a change in the pkgname variable will result in a custom kernels, installable side-by-side with Arhc's stock one.
    The advantages of this approach:
    1) Nothing changes for devs
    2) Simplification of custom kernel building
    3) Easier testing of patches
    4) Easier testing of new kernels
    There is not much modification for the PKGBUILD. It mainly adds the possibility to give a special name to the package like this : pkgname=kernel26-mypatchset. Then, through the LOCAVERSION in the config file, folders and files will have the "-mypatchset" suffix. For example :
    /boot/vmlinuz26-mypatchset
    /etc/mkinitcpio.d/kernel26-mypatchset.preset
    /lib/modules/2.6.27-mypatchset/
    /usr/src/linux-2.6.27-mypatchset/
    etc.
    To build Arch's stock kernel, just keep "pkgname=kernel26" and it will build as before.
    This is something I am using right now. Would other people be interested? Could it be included included in the distribution?
    I hope it will help others.
    big_gie
    EDITs:
    2009-02-04:
    -Bump version to 2.6.28.2-1 (from core)
    2009-01-21:
    -Added corrections from the bug report (http://bugs.archlinux.org/task/12384)
    -Bump version to 2.6.28.1 (from core)
    2008-12-07:
    -Cleaned the patch, some comments
    2008-12-01:
    -Corrected problem where initrd files were overwritten
    -Updated to 2.6.27.7
    kernel26-2.6.28.1-1-personnal.patch REMOVED. Please check bug report at http://bugs.archlinux.org/task/12384 for the latest patch. This should prevent bad copy/paste from the forum...
    Last edited by big_gie (2009-02-05 04:22:58)

    Seems like a good idea, I'm not that advanced so what I saw looks like a nice idea. I do have another solution that I use if you want a kernel installed side by side in your grub list that will allow your Stock -ARCH kernel to not be ruined and still allow updates.
    What I do is I have my custom PKGBUILD that I made from modifying an ABS kernel26 PKGBUILD. I give the kernel a different pkgname such as kernel26zen3.
    I also change the "_patchname=-ARCH" to the name of my patchset like zen2 or zen3 so it looks like this: "_patchset=-zen3". Then I add this line to the line above "make menuconfig": "_kernver="${_basekernel}${_patchset}" so it writes "2.6.27-zen3" for the kernver.
    I also include the kernel26.preset and kernel26.install and rename them to use my new pkgname so they are called: kernel26zen3.preset and kernel26zen3.install..... I also modify both of those files to use the appropriate names and versions as well as anything in the PKGBUILD.
    This builds me a separate "kernel26zen3" that has a separate "vmlinuz26zen3", "System.map26zen3", "kernel26zen3.img", and "kerenl26zen3fallback.img" in the /boot directory, and a separate "2.6.27-zen3" directory in /lib/modules, and also a separate "linux-2.6.27-zen3" in /usr/src. It also adds a "kernel26zen3.kver" and "kernel26zen3.preset" to the /etc/mkinitcpio.d directory.
    Then I add my kernel26zen3 kernel to my grub list, if I run into any problems with it, I can still boot into my stock -ARCH kernel or my Vista partition.
    This is me using my zen3 kernel while I still have my other stock -ARCH kernel installed..... I just updated the stock kernel while logged into my kernel26zen3 that I use as my default kernel.....
    [seventy3@HPdv9920us ~]$ uname -r
    2.6.27-zen3
    [seventy3@HPdv9920us ~]$ pacman -Q kernel26zen3
    kernel26zen3 2.6.27-1
    [seventy3@HPdv9920us ~]$ pacman -Q kernel26
    kernel26 2.6.27.7-1
    [seventy3@HPdv9920us ~]$
    I also didn't mean to hijack your thread or anything.
    Last edited by methuselah (2008-12-01 23:21:30)

  • Will Elements or lightroom batch autorotate jpeg images losslessly?

    Need to process folders automatically....

    A related question as I am also wondering about Lightroom.
    One of the features I love about PSE8 Organizor is the ability to synch albums directly from itunes to my ipod touch.
    If light room is loaded does it appear under the photo tab as an option to import albums?
    Thanks
    KSM

  • Rotate image lossless

    Hello,
    is there a method in java to rotate an jpeg image lossless?
    So that all meta informations keep exists and the picture has the same quality?
    Thank you
    Johannes

    I try it with AffineTransform but I always loss after save the new Image all Metadata and I think the Image has not the same Quality.
    Thats my Code:
        BufferedImage i = null;
        IIOMetadata imeta = null;
          ImageInputStream iis = ImageIO.createImageInputStream(file);
          ImageReader reader = ImageIO.getImageReadersByFormatName("jpg").next();
          reader.setInput(iis,true);
          ImageReadParam params = reader.getDefaultReadParam();
          sourceBI =  reader.read(0,params);
          imeta = reader.getImageMetadata(0);
        BufferedImage sourceBI = new BufferedImage(X, Y, BufferedImage.TYPE_INT_RGB);
        AffineTransform at = new AffineTransform();
        at.rotate(Math.toRadians( angel ), (sourceBI.getWidth() / 2), (sourceBI.getHeight() / 2) );
        AffineTransform translationTransform;
        translationTransform = findTranslation( at, sourceBI, 90);
        at.preConcatenate( translationTransform );
        Graphics2D g = (Graphics2D) sourceBI.getGraphics();
        g.setTransform(at);
        g.drawImage(inputImage, 0, 0, null);
          FileOutputStream fos = new FileOutputStream(file);
          ImageWriter writer = ImageIO.getImageWritersByFormatName("jpg").next();
          ImageOutputStream ios = ImageIO.createImageOutputStream(fos);
          writer.setOutput(ios);
          ImageWriteParam iwparam = new JPEGImageWriteParam(Locale.getDefault());
          iwparam.setCompressionMode(ImageWriteParam.MODE_EXPLICIT);
          // set JPEG Quality
          iwparam.setCompressionQuality(0.92f);
          writer.write(imeta, new IIOImage(sourceBI, null, null), iwparam);
          ios.flush();
          writer.dispose();
          ios.close();
          fos.close();That's the findTranslation Method:
      private static AffineTransform findTranslation(AffineTransform at, BufferedImage bi, int angel ) {
        Point2D p2din, p2dout;
        double ytrans, xtrans = 0.0;
        AffineTransform tat = new AffineTransform();
        if(angel == 180){
          p2din = new Point2D.Double(0, bi.getHeight());
        }else{
          p2din = new Point2D.Double(0.0, 0.0);
        p2dout = at.transform(p2din, null);
        if(angel == 270){
          xtrans = p2dout.getX();
          ytrans = xtrans;
        }else{
          ytrans = p2dout.getY();
          xtrans = ytrans;
        tat.translate(-xtrans, -ytrans);
        return tat;
      }When I set the quality for the target picture to hight the target picture size is higher the from the source picture.
    What can I do to rotate lossless and keep the Meta Information?
    Johannes

  • I am trying to use photomerge compose.  I open one standard jpeg image and one image that is my business logo in a png format.  When I select the png image, to extract the logo from it, it appears as all white and will not allow me to select the logo from

    I am trying to use photomerge compose.  I open one standard jpeg image and one image that is my business logo in a png format.  When I select the png image, to extract the logo from it, it appears as all white and will not allow me to select the logo from it.  It has worked in the past but I downloaded the update today and photomerge will not work correctly.  Any ideas?

    hedger,
    How do you expect anyone to help when we don't know a darned thing about the file, abut your setup, exact version of Photoshop and your OS, machine specs, etc.?
    BOILERPLATE TEXT:
    Note that this is boilerplate text.
    If you give complete and detailed information about your setup and the issue at hand,
    such as your platform (Mac or Win),
    exact versions of your OS, of Photoshop (not just "CS6", but something like CS6v.13.0.6) and of Bridge,
    your settings in Photoshop > Preference > Performance
    the type of file you were working on,
    machine specs, such as total installed RAM, scratch file HDs, total available HD space, video card specs, including total VRAM installed,
    what troubleshooting steps you have taken so far,
    what error message(s) you receive,
    if having issues opening raw files also the exact camera make and model that generated them,
    if you're having printing issues, indicate the exact make and model of your printer, paper size, image dimensions in pixels (so many pixels wide by so many pixels high). if going through a RIP, specify that too.
    etc.,
    someone may be able to help you (not necessarily this poster, who is not a Windows user).
    a screen shot of your settings or of the image could be very helpful too.
    Please read this FAQ for advice on how to ask your questions correctly for quicker and better answers:
    http://forums.adobe.com/thread/419981?tstart=0
    Thanks!

  • I use Photoshop Elements 11 to print panoramas. Works for jpeg images but not tiff. Suggestions?

    I use Photoshop Elements 11 to print panoramas. It works for jpeg images but not for tiff images. Seems strange because PSE11 manages tiff images in all other processes. Anyone fared better?

    Thank you for your trouble.
    My images are not usually layered and the particular case I am about to quote, it is not. The dimensions are 10,546 x 2,790 and the image has 16.7 mbs. I use 8 bit colour. When I set up the print screens for tiff, everything is normal until I get to the last screen with the image set upon the photo paper. Then the paper size indicated with the image refuses to budge from the A4 size, so the panorama gets printed on that. I consulted the Adobe chat line and the expert could 't get it to work either. So he came to the conclusion that the tiff capability had not been extended to printing panoramas. In seeking advice, I thought someone might refer me to an updating patch!
    Well done! You have confounded the system!  I could not find any control that would override the setting.

  • ID ePUB export converts all *inline* anchored JPEG images to PNG?

    During ePUB export, when Image Conversion = Automatic, anchored JPEG images with Position = Inline are converted to PNG. If Anchored Object Position = Custom, the same images stay JPEG. Anyone know a better way to avoid than the less-than-ideal options below?
    Less than idea options:
    a) Use Image Conversion = JPEG (would also convert existing .gif and .png images)
    b) Specify Object Export Options for each image frame that contains a JPEG.
    Maybe this is just a bug.

    Here's the definition from the InDesign Help file:
    Image Conversion
    Lets you choose whether the optimized images in your document are converted to GIF, JPEG, or PNG. Choose Automatic to let InDesign decide which format to use in each instance. Choosing PNG disables the image compression settings; use PNG for lossless images or for images that include transparency.
    Choosing Automatic means InDesign decides which format to use. It doesn't mean keep the same format.

  • How to get crisp jpeg images for slideshow on a Mac with Final Cut?

    Hi, I imported a large number of jpegs into Final Cut Pro and when I export to Quicktime Movie (not modifying the sequence size or settings I notice the quality of the jpeg images looks rather washed out and a bit fuzzy. The image dimensions of the jpegs are actually 2848 x 4272 and I was originally using a sequence setting of 720 by 480 (which scaled the images to about 12%). I experimented with doubling the sequence setting to 1440 by 960 and scaled the images to about 25.5% - still a bit washed out look.
    Basically this will be a presentation on a computer and output via projection. Looking for best possible and clearest photos. I experimented with iPhoto and when you play a slideshow it looks very crisp - this is what I am aiming for. When I export using the Slideshow export at the largest size 640 by 480 in iPhoto to quicktime - the quality seriously deteriorates.
    What would be the best way to maintain the crispness of the photos in Final Cut for an export to Quicktime that would be show on a Mac via a projector? Thank you

    Hi Nick, I do see information on creating a slideshow with Quicktime at: http://www.apple.com/quicktime/tutorials/slideshow.html
    however it appears Quicktime X removed that capability. There is no 'open image sequence' option from the File menu in Quicktime X.
    If I do end up sticking with Final Cut - would you recommend any codec and/or dimension size that would result in the best quality or the most crisp image? I also need a few fade in's and out's on various parts - I don't believe I would have the control without Final Cut.
    Would resizing the image files in Photoshop to 1920 pixels by 1280 before importing them into Final Cut result in crisper images? Thanks.

  • How can I add a title and ALT text to a JPEG image in Elements 11 for MAC?

    Does anyone know if there is an easy way I can add a title and ALT text to a JPEG image in Elements 11 for MAC?
    Very grateful for any help here.

    Hello
    The Arrange menu is your friend.
    You may select the arrow then "Bring to Front".
    Yvan KOENIG (from FRANCE vendredi 19 septembre 2008 17:49:50)

  • Fix for jittery jpeg images in FCE?

    Hi,
    I recently created a 25th wedding anniversary video for a friend of mine. Basically, I used jpeg images to which I applied motion (slow zooms, pans, etc). I noticed that when I rendered the movie, I got some jitters through some of the edit points. I rendered and re-rendered, but the jitters remained (they were in exactly the same place through the various conversions: eg. in the QuickTime movie and on the final DVD). Very frustrating. I normally edit on a preset canvas for HD, and don't have any problems. However, this time I selected 720x480 DV/DVCPRO - NTSC, since I didn't want to use the full size of 1920x1080 HD resolution ( mainly because I also incorporated some captured clips from VHS tapes).
    Did I select the wrong preset for the canvas? Could this be why I'm getting the jittery edits? Or, perhaps it has something to do with timecode? I'm not very technical-minded; don't have a clue, in fact. Anyone have any experience with using jpegs in your movies and overcoming jitters? And, what preset for the canvas should I use for these kinds of projects?
    Thanks very much!
    Vic

    Try using the De-interlace Filter on them.

  • TS3276 Having trouble sending jpeg images as attachments in Mac email.....they go thru as images and PC users can't see the SAVE or QUICK LOOK boxes that Mac mail has.  One friend scrolled over the image, right clicked on it and saved as a PNG file.

    Having trouble sending jpeg images as attachments in Mac email.....they go thru as images and PC users can't see the SAVE or QUICK LOOK boxes that Mac mail has.  One friend scrolled over the image, right clicked on it and saved as a PNG file.

    Apple Mail isn't going to change the format of any of your attachments. it isn't going to corrupt them either.
    Exchange is a transport protocol and server. The issue you describe is not related to Exchange.
    There are many different versions of Microsoft Outlook in use and they all have e-mail bugs. Different versions have different bugs. Some Apple Mail hack to get around a bug in Outlook 2003 may cause the same message to be problematic in Outlook 2000. Fix them both and another issue will cause trouble in Outlook 2007. You can't fix this. Apple can't fix this. Microsoft can and has but that is irrelevant if your recipients are using older versions.
    One specific problem is that Apple Mail always sends image attachments inline, as images, not as iconized files. You can change this with Attachment Tamer. Just be aware that use of this software will break other things such as Stationery. E-mail is just a disaster. To date, no one outside of Apple has ever implemented the e-mail standards from 1993. Apple has continually changed its e-mail software to be more compatible with the de-facto standards that Netscape and Microsoft have unilaterally defined and people documented as "standards" after the fact. The e-mail messages that Apple Mail sends are 100% correct and do not violate any of the original standards from 1993 or the Microsoft/Netscape modifications. The problem is entirely bugs and limitations in various versions of Outlook.

  • Save for web as PNG-24 with slices is saving in JPEG format!

    Hello all.
    I'm using Photoshop Extended CS6 13.0.1 x64 and when I save for web as PNG-24, all the slices from the project, the final result are JPEG format pictures. I tried the same but exporting as GIF and it keeps saving as JPEG. I tried Save As instead of Save for Web and it works, but this way I'm not saving by slice and not for web.
    Any idea why this happens?

    Found the solution. I had to select all the slices.

  • How to create a white back ground for Jpeg image to upload on various webites

    Hello, I have Photoshop Elements 11. I designed a book cover with Microsoft Word 2010 and saved the file as a Pdf. I want to upload an image of this book cover to various web sites that require a Jpeg image and the book cover has to cover at least 85% of the image and require a pure white back ground. Pixel size can be 1,000 or more. Can somebody help me? I did go to the library to get reference books but, I can't ascertain from these books how to do this. I am a beginner to Photoshop and realize I will have to get training for future projects. Thank you very much for any information you provide to me. I wanted to upload an image from my computer to show you the book cover but there was a dialogue box that appeared saying the file was too large to upload. The book cover I designed is 8.5' x 11.0"

    Wow! I can't thank you enough! There is not enough space here for me to express my gratitude for helping me! You are a saint! I had the Pdf files uploaded and stored in my organizer, so the images of the book covers appeared in the bottom of Photoshop Elements 11 Editor. I did exactly as you instructed, then sent the Jpeg  to Amazon and it uploaded in less than 5 minutes. The image could be a little bigger, but now I can utilize the software enough to tweak it.Thanks so much!!!! Any other ideas would be greatly appreciated. Take care and have a great 2013!

  • Marydee-You asked me about resizing apps for jpeg images & how 2 get info

    Marydee- You asked me about resizing apps for jpeg images. And you also asked how to get photo info for each image in iphoto
    Here's what I found in the iPhoto6 Help Menu:
    Showing a photo's image and camera information
    iPhoto stores EXIF information with each photo in your library. This information includes the photo's image size, the date and time it was taken, and the type of camera it was taken on, as well as important exposure information, such as the shutter speed, aperture, and film ISO.
    To show image and camera information:
    Select the photo and choose Photos > Get Info.
    You can also see a photo's title, date taken, rating, format, and comments by clicking the Information button in the bottom-left corner of the iPhoto window.
    Also please take a look at these prior discussions in iPhoto Forum/s:
    http://discussions.apple.com/thread.jspa?messageID=3212997&#3212997
    http://discussions.apple.com/thread.jspa?messageID=4535542&#4535542
    http://kstudio.net/re.html
    Hope the above helps and good luck on this.
    (3) G4 PM's/(3) S-Drives/Sony TRV900/Nikons/6FWHD's/PS7/iLife06/FCPHD/DVDSP/etc.   Mac OS X (10.4.8)  

    Marydee- You asked me about resizing apps for jpeg images. And you also asked how to get photo info for each image in iphoto
    Here's what I found in the iPhoto6 Help Menu:
    Showing a photo's image and camera information
    iPhoto stores EXIF information with each photo in your library. This information includes the photo's image size, the date and time it was taken, and the type of camera it was taken on, as well as important exposure information, such as the shutter speed, aperture, and film ISO.
    To show image and camera information:
    Select the photo and choose Photos > Get Info.
    You can also see a photo's title, date taken, rating, format, and comments by clicking the Information button in the bottom-left corner of the iPhoto window.
    Also please take a look at these prior discussions in iPhoto Forum/s:
    http://discussions.apple.com/thread.jspa?messageID=3212997&#3212997
    http://discussions.apple.com/thread.jspa?messageID=4535542&#4535542
    http://kstudio.net/re.html
    Hope the above helps and good luck on this.
    (3) G4 PM's/(3) S-Drives/Sony TRV900/Nikons/6FWHD's/PS7/iLife06/FCPHD/DVDSP/etc.   Mac OS X (10.4.8)  

  • Hyperlinks for jpeg images?

    I am trying to send an email to friends that has an image they can click on to go directly to my website. It is a logo for a fantasy golf pool that they are all familiar with and have been trained to click on for the past 5 years when I was using Outlook Express on a Windows 98 computer.
    When I try to add hyperlink to an image in Mail, the image disappears and is replaced by a text hyperlink of my bulky web.mac address.
    I have searched these discussions and found others frustrated by this same thing and there seems to be no solution. I read "jpeg encodes images in a series of bytes, so as you now probably realize you can't put a link directly into this format." I've also read that you would have to code your own HTML to accomplish this.
    It's hard for me to believe that my brand new kick butt Mac can't do what my outdated PC could do with one click and no HTML. Please, someone tell me it's not true.

    > It's hard for me to believe that my brand new kick butt Mac can't do what my outdated PC could do with one click and no HTML.
    You didn't realize it but you were using HTML with OE on your outdated Windows PC in order to make this work. It is impossible to make an image a hyperlink without composing in HTML. The image must be embedded in the message body for this to work and although image/photo and single page PDF attachments appear inline or viewed in place within the body of the message by default with the Mail.app for received and sent messages, this is not the same thing as embedded which requires HTML.
    RTF with Tiger Mail is really HTML but Mail does not include an HTML composer/editor. In order to turn RTF into HTML requires selecting a font via the font panel when composing a message or if an included signature was composed in RTF.
    You can experiment with using an HTML composer/editor of choice (the Text Edit application can be used for this purpose) turning an image into a hyperlink. Save the completed document and open the saved document with Safari making sure the hyperlink is working properly.
    At the Safari menu bar, go to File and select Mail Contents of This Page. With RTF selected for message composition with Mail, the saved HTML document that is rendered with Safari will be copied to a new Mail.app which will be sent in its entirety.

Maybe you are looking for

  • External Preloader

    We have a tne of flash apps that all need the same preloader added. Problem is that the preloader look will change often. Can you have each app call on an external file as its preloader? That way, we only have to change the 1 external file. If so, wh

  • Change date/time layout in server.log to show milliseconds

    Hi, I need to debug the JDBC session to find delays in my source. I used following to get the JDBC debug info: -Dweblogic.Debug=weblogic.JDBCConn,weblogic.JDBCSQL My problem is that the layout of the server log file does not show the milliseconds, it

  • Customizing the graph in the report

    1-In the next version is that possible to change some parameter in the graph of reports such as diameter in the ring graph. 2- Can I add my graph which i want in the report , not the default graph in the report builder. i mean different shapes

  • Has anyone tried the Zeiss Screen Eraser on their iphone 5?

    Carl Zeiss company is known for fine optical gear.  When I tried locally to find a flat-weave microfiber cloth for cleaning my iPhone 5, all I could find was a kit with the cloth and a Zeiss Screen Eraser, made for cleaning LCD screens and touch scre

  • Thumbnails do not match video content when imported

    My thumbnails do not match video content when imported. They assume the look of the first video imported into an event, while showing correct source content when skimmed through. Also, audio for every video clip I import is changed to that of the fir