Ticket #13306: mythburn-RGBA-JPEG.patch

File mythburn-RGBA-JPEG.patch, 4.3 KB (added by jreiser, 11 months ago)

patch mythburn.py to detour through RGB when saving to JPEG

  • (a) mythburh.py.orig vs. (b) mythburn.py

    a b  
    36163616        bgimage.paste(overlayimage, (0,0), overlayimage)
    36173617
    36183618        #Save this menu image and its mask
    3619         bgimage.save(os.path.join(getTempPath(),"background-%s.jpg" % page),"JPEG", quality=99)
     3619        rgb_bgimage=bgimage.convert('RGB')  # https://stackoverflow.com/questions/43258461/convert-png-to-jpeg-using-pillow-in-python
     3620        rgb_bgimage.save(os.path.join(getTempPath(),"background-%s.jpg" % page),"JPEG", quality=99)
     3621        del rgb_bgimage
    36203622        bgimagemask.save(os.path.join(getTempPath(),"backgroundmask-%s.png" % page),"PNG",quality=99,optimize=0,dpi=screendpi)
    36213623
    36223624        #now that the base background has been made and all the previews generated
     
    36543656                            del picture
    36553657                    previewitem+=1
    36563658                #bgimage.save(os.path.join(getTempPath(),"background-%s-f%06d.png" % (page, framenum)),"PNG",quality=100,optimize=0,dpi=screendpi)
    3657                 bgimage.save(os.path.join(getTempPath(),"background-%s-f%06d.jpg" % (page, framenum)),"JPEG",quality=99)
     3659                rgb_bgimage=bgimage.convert('RGB')  # https://stackoverflow.com/questions/43258461/convert-png-to-jpeg-using-pillow-in-python
     3660                rgb_bgimage.save(os.path.join(getTempPath(),"background-%s-f%06d.jpg" % (page, framenum)),"JPEG",quality=99)
     3661                del rgb_bgimage
    36583662                framenum+=1
    36593663
    36603664        spumuxdom.documentElement.firstChild.firstChild.setAttribute("select",os.path.join(getTempPath(),"backgroundmask-%s.png" % page))
     
    38213825        #Save this menu image and its mask
    38223826        bgimage=Image.open(backgroundfilename,"r").resize(screensize)
    38233827        bgimage.paste(overlayimage, (0,0), overlayimage)
    3824         bgimage.save(os.path.join(getTempPath(),"chaptermenu-%s.jpg" % page),"JPEG", quality=99)
     3828        rgb_bgimage=bgimage.convert('RGB')  # https://stackoverflow.com/questions/43258461/convert-png-to-jpeg-using-pillow-in-python
     3829        rgb_bgimage.save(os.path.join(getTempPath(),"chaptermenu-%s.jpg" % page),"JPEG", quality=99)
     3830        del rgb_bgimage
    38253831
    38263832        bgimagemask.save(os.path.join(getTempPath(),"chaptermenumask-%s.png" % page),"PNG",quality=90,optimize=0)
    38273833
     
    38503856                                bgimage.paste(picture, (previewx[previewchapter], previewy[previewchapter]))
    38513857                            del picture
    38523858                    previewchapter+=1
    3853                 bgimage.save(os.path.join(getTempPath(),"chaptermenu-%s-f%06d.jpg" % (page, framenum)),"JPEG",quality=99)
     3859                rgb_bgimage=bgimage.convert('RGB')  # https://stackoverflow.com/questions/43258461/convert-png-to-jpeg-using-pillow-in-python
     3860                rgb_bgimage.save(os.path.join(getTempPath(),"chaptermenu-%s-f%06d.jpg" % (page, framenum)),"JPEG",quality=99)
     3861                del rgb_bgimage
    38543862                framenum+=1
    38553863
    38563864        spumuxdom.documentElement.firstChild.firstChild.setAttribute("select",os.path.join(getTempPath(),"chaptermenumask-%s.png" % page))
     
    39713979        #Save this details image
    39723980        bgimage=Image.open(backgroundfilename,"r").resize(screensize)
    39733981        bgimage.paste(overlayimage, (0,0), overlayimage)
    3974         bgimage.save(os.path.join(getTempPath(),"details-%s.jpg" % itemnum),"JPEG", quality=99)
     3982        rgb_bgimage=bgimage.convert('RGB')  # https://stackoverflow.com/questions/43258461/convert-png-to-jpeg-using-pillow-in-python
     3983        rgb_bgimage.save(os.path.join(getTempPath(),"details-%s.jpg" % itemnum),"JPEG", quality=99)
     3984        del rgb_bgimage
    39753985
    39763986        if haspreview == True:
    39773987            numframes=secondsToFrames(menulength)
     
    39944004                        else:
    39954005                            bgimage.paste(picture, (previewx, previewy))
    39964006                        del picture
    3997                 bgimage.save(os.path.join(getTempPath(),"details-%s-f%06d.jpg" % (itemnum, framenum)),"JPEG",quality=99)
     4007                rgb_bgimage=bgimage.convert('RGB')  # https://stackoverflow.com/questions/43258461/convert-png-to-jpeg-using-pillow-in-python
     4008                rgb_bgimage.save(os.path.join(getTempPath(),"details-%s-f%06d.jpg" % (itemnum, framenum)),"JPEG",quality=99)
     4009                del rgb_bgimage
    39984010                framenum+=1
    39994011
    40004012