[Bf-extensions-cvs] [272e9b17] master: io_import_gimp_image_to_scene: move to contrib: T63750

meta-androcto noreply at git.blender.org
Fri May 24 03:55:15 CEST 2019


Commit: 272e9b17723c4260c4ed6f9a91cfed51d4b7fb1d
Author: meta-androcto
Date:   Fri May 24 11:54:54 2019 +1000
Branches: master
https://developer.blender.org/rBA272e9b17723c4260c4ed6f9a91cfed51d4b7fb1d

io_import_gimp_image_to_scene: move to contrib: T63750

===================================================================

D	io_import_gimp_image_to_scene.py

===================================================================

diff --git a/io_import_gimp_image_to_scene.py b/io_import_gimp_image_to_scene.py
deleted file mode 100644
index f967caaa..00000000
--- a/io_import_gimp_image_to_scene.py
+++ /dev/null
@@ -1,692 +0,0 @@
-# ##### BEGIN GPL LICENSE BLOCK #####
-#
-#  This program is free software; you can redistribute it and/or
-#  modify it under the terms of the GNU General Public License
-#  as published by the Free Software Foundation; either version 2
-#  of the License, or (at your option) any later version.
-#
-#  This program is distributed in the hope that it will be useful,
-#  but WITHOUT ANY WARRANTY; without even the implied warranty of
-#  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-#  GNU General Public License for more details.
-#
-#  You should have received a copy of the GNU General Public License
-#  along with this program; if not, write to the Free Software Foundation,
-#  Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
-#
-# ##### END GPL LICENSE BLOCK #####
-
-bl_info = {
-    "name": "Import GIMP Image to Scene (.xcf/.xjt)",
-    "author": "Daniel Salazar (ZanQdo)",
-    "version": (2, 0, 1),
-    "blender": (2, 73, 0),
-    "location": "File > Import > GIMP Image to Scene(.xcf/.xjt)",
-    "description": "Imports GIMP multilayer image files as a series of multiple planes",
-    "warning": "XCF import requires xcftools installed",
-    "wiki_url": "http://wiki.blender.org/index.php/Extensions:2.6/Py/"
-                "Scripts/Import-Export/GIMPImageToScene",
-    "category": "Import-Export",
-}
-
-"""
-This script imports GIMP layered image files into 3D Scenes (.xcf, .xjt)
-"""
-
-def main(report, File, Path, LayerViewers, MixerViewers, LayerOffset,
-         LayerScale, OpacityMode, AlphaMode, ShadelessMats,
-         SetCamera, SetupCompo, GroupUntagged, Ext):
-
-    #-------------------------------------------------
-
-    #Folder = '['+File.rstrip(Ext)+']'+'_images/'
-    Folder = 'images_'+'['+File.rstrip(Ext)+']/'
-
-    if not bpy.data.is_saved:
-        PathSaveRaw = Path+Folder
-        PathSave = PathSaveRaw.replace(' ', '\ ')
-        try: os.mkdir(PathSaveRaw)
-        except: pass
-    else:
-        PathSave = bpy.data.filepath
-        RSlash = PathSave.rfind('/')
-        PathSaveRaw = PathSave[:RSlash+1]+Folder
-        PathSave = PathSaveRaw.replace(' ', '\ ')
-        try: os.mkdir(PathSaveRaw)
-        except: pass
-        PathSaveRaw = bpy.path.relpath(PathSaveRaw)+'/'
-
-    PathRaw = Path
-    Path = Path.replace(' ', '\ ')
-    if Ext == '.xjt':
-        ExtSave = '.jpg'
-        #-------------------------------------------------
-        # EXTRACT XJT
-        import tarfile
-
-        IMG = tarfile.open ('%s%s' % (PathRaw, File))
-        PRP = IMG.extractfile('PRP')
-
-        Members = IMG.getmembers()
-
-        for Member in Members:
-            Name = Member.name
-            if Name.startswith('l') and Name.endswith('.jpg'):
-                IMG.extract(Name, path=PathSaveRaw)
-
-        #-------------------------------------------------
-        # INFO XJT
-        IMGs = []
-        for Line in PRP.readlines():
-            Line = str(Line)
-
-            if Line.startswith("b'GIMP_XJ_IMAGE"):
-                for Segment in Line.split():
-                    if Segment.startswith('w/h:'):
-                        ResX, ResY = map (int, Segment[4:].split(','))
-            if Line.startswith(("b'L", "b'l")):
-
-                """The "nice" method to check if layer has alpha channel
-                sadly GIMP sometimes decides not to export an alpha channel
-                if it's pure white so we are not completely sure here yet"""
-                if Line.startswith("b'L"): HasAlpha = True
-                else: HasAlpha = False
-
-                md = None
-                op = 1
-                ox, oy = 0,0
-
-                for Segment in Line.split():
-
-                    if Segment.startswith("b'"):
-                        imageFile = 'l' + Segment[3:] + '.jpg'
-                        imageFileAlpha ='la'+Segment[3:]+'.jpg'
-
-                        """Phisically double checking if alpha image exists
-                        now we can be sure! (damn GIMP)"""
-                        if HasAlpha:
-                            if not os.path.isfile(PathSaveRaw+imageFileAlpha): HasAlpha = False
-
-                        # Get Width and Height from images
-                        data = open(PathSaveRaw+imageFile, "rb").read()
-
-                        hexList = []
-                        for ch in data:
-                            byt = "%02X" % ch
-                            hexList.append(byt)
-
-                        for k in range(len(hexList)-1):
-                            if hexList[k] == 'FF' and (hexList[k+1] == 'C0' or hexList[k+1] == 'C2'):
-                                ow = int(hexList[k+7],16)*256 + int(hexList[k+8],16)
-                                oh = int(hexList[k+5],16)*256 + int(hexList[k+6],16)
-
-                    elif Segment.startswith('md:'): # mode
-                        md = Segment[3:]
-
-                    elif Segment.startswith('op:'): # opacity
-                        op = float(Segment[3:])*.01
-
-                    elif Segment.startswith('o:'): # origin
-                        ox, oy = map(int, Segment[2:].split(','))
-
-                    elif Segment.startswith('n:'): # name
-                        n = Segment[3:-4]
-                        OpenBracket = n.find ('[')
-                        CloseBracket = n.find (']')
-
-                        if OpenBracket != -1 and CloseBracket != -1:
-                            RenderLayer = n[OpenBracket+1:CloseBracket]
-                            NameShort = n[:OpenBracket]
-
-                        else:
-                            RenderLayer = n
-                            NameShort = n
-
-                        os.rename(PathSaveRaw+imageFile, PathSaveRaw+NameShort+'.jpg')
-                        if HasAlpha: os.rename(PathSaveRaw+imageFileAlpha, PathSaveRaw+NameShort+'_A'+'.jpg')
-
-                IMGs.append({'LayerMode':md, 'LayerOpacity':op,
-                            'LayerName':n, 'LayerNameShort':NameShort,
-                            'RenderLayer':RenderLayer, 'LayerCoords':[ow, oh, ox, oy], 'HasAlpha':HasAlpha})
-
-    else: # Ext == '.xcf':
-        ExtSave = '.png'
-        #-------------------------------------------------
-        # CONFIG
-        XCFInfo = 'xcfinfo'
-        XCF2PNG = 'xcf2png'
-        #-------------------------------------------------
-        # INFO XCF
-
-        try:
-            Info = subprocess.check_output((XCFInfo, Path+File))
-        except FileNotFoundError as e:
-            if XCFInfo in str(e):
-                report({'ERROR'}, "Please install xcftools, xcfinfo seems to be missing (%s)" % str(e))
-                return False
-            else:
-                raise e
-
-        Info = Info.decode()
-        IMGs = []
-        for Line in Info.split('\n'):
-            if Line.startswith ('+'):
-
-                Line = Line.split(' ', 4)
-
-                RenderLayer = Line[4]
-
-                OpenBracket = RenderLayer.find ('[')
-                CloseBracket = RenderLayer.find (']')
-
-                if OpenBracket != -1 and CloseBracket != -1:
-                    RenderLayer = RenderLayer[OpenBracket+1:CloseBracket]
-                    NameShort = Line[4][:OpenBracket]
-                else:
-                    NameShort = Line[4].rstrip()
-                    if GroupUntagged:
-                        RenderLayer = '__Undefined__'
-                    else:
-                        RenderLayer = NameShort
-
-                LineThree = Line[3]
-                Slash = LineThree.find('/')
-                if Slash == -1:
-                    Mode = LineThree
-                    Opacity = 1
-                else:
-                    Mode = LineThree[:Slash]
-                    Opacity = float(LineThree[Slash+1:LineThree.find('%')])*.01
-
-                IMGs.append ({
-                    'LayerMode': Mode,
-                    'LayerOpacity': Opacity,
-                    'LayerName': Line[4].rstrip(),
-                    'LayerNameShort': NameShort,
-                    'LayerCoords': list(map(int, Line[1].replace('x', ' ').replace('+', ' +').replace('-', ' -').split())),
-                    'RenderLayer': RenderLayer,
-                    'HasAlpha': True,
-                    })
-            elif Line.startswith('Version'):
-                ResX, ResY = map (int, Line.split()[2].split('x'))
-
-        #-------------------------------------------------
-        # EXTRACT XCF
-        if OpacityMode == 'BAKE':
-            Opacity = ()
-        else:
-            Opacity = ("--percent", "100")
-        xcf_path = Path + File
-        for Layer in IMGs:
-            png_path = "%s%s.png" % (PathSave, Layer['LayerName'].replace(' ', '_'))
-            subprocess.call((XCF2PNG, "-C", xcf_path, "-o", png_path, Layer['LayerName']) + Opacity)
-
-    #-------------------------------------------------
-    Scene = bpy.context.scene
-    #-------------------------------------------------
-    # CAMERA
-
-    if SetCamera:
-        bpy.ops.object.camera_add(location=(0, 0, 10))
-
-        Camera = bpy.context.active_object.data
-
-        Camera.type = 'ORTHO'
-        Camera.ortho_scale = ResX * .01
-
-    #-------------------------------------------------
-    # RENDER SETTINGS
-
-    Render = Scene.render
-
-    if SetCamera:
-        Render.resolution_x = ResX
-        Render.resolution_y = ResY
-        Render.resolution_percentage = 100
-    Render.film_transparent = True
-
-    #-------------------------------------------------
-    # 3D VIEW SETTINGS
-
-    Scene.game_settings.material_mode = 'GLSL'
-
-    Areas = bpy.context.screen.areas
-
-    for Area in Areas:
-        if Area.type == 'VIEW_3D':
-            Area.spaces.active.viewport_shade = 'TEXTURED'
-            Area.spaces.active.show_textured_solid = True
-            Area.spaces.active.show_floor = False
-
-    #-------------------------------------------------
-    # 3D LAYERS
-
-    def Make3DLayer (Name, NameS

@@ Diff output truncated at 10240 characters. @@



More information about the Bf-extensions-cvs mailing list