Import: Images mapped to planes
Closed, ArchivedPublic

Description

Project: Blender Extensions
Tracker: Py Scripts Release
Blender: 2.66
Python: 3.3
Script name: io_import_images_as_planes.py
Wiki page: http://wiki.blender.org/index.php/Extensions:2.6/Py/Scripts/Add_Mesh/Planes_from_Images
Author(s): Florian Meyer (tstscr)
Category: Import Export
SVN Download: https://svn.blender.org/svnroot/bf-extensions/trunk/py/scripts/addons/io_import_images_as_planes.py
Status: Open

This script imports images and creates Planes with them as textures.
At the moment the naming for objects, materials, textures and meshes is derived from the imagename.
One can either import a single image,
or all images in one directory.
When imporing a directory one can either check the checkbox or leave the filename empty.

As a bonus one can choose to import images of only one type.
Atm this is the list of possible extensions:
extList = ('jpeg', 'jpg', 'png', 'tga', 'tiff', 'tif', 'exr', 'hdr', 'avi', 'mov', 'mp4', 'ogg', 'bmp', 'cin', 'dpx')

If someone knows a better way of telling if a file is an image which blender can read, please tell so ;)

when importing images that are allready referenced they are not reimported but the old ones reused as not to clutter the
materials, textures and image lists.
instead the plane gets linked against an existing material.

there is still more stuff to do.

V 0.2

I have rewritten the whole thing.
It is much cleaner now as well as cluttered with comments.

kinda new is:
If one reimports images but chooses different material/texture mapping new materials are created.
so one doesn't has to go through everything if one decides differently after importing 236 images.

V 0.3

more Cleanup by pontiac

V 0.4

-added psd to image list
-images are now assigned to UVLayer as well and respect alpha

V 0.5

-fixed the detection of existing materials/textures with the chosen mapping
-should now work as advertised in all situations

-have added a custom dynamic property to the base MaterialClass.
i don't know if that's good behavior or not

V 0.6

-respects align to view userpref now
-added to the addmesh menu

moved to contrib.
changed name for consistency.

While we are talking I'm noting down some feature request:

a) selecting many images -> does many planes
b) selecting many images -> ask to put the as texture channels in a single plane
c) selecting a xcf file (GIMP) -> put layers as (a) or (b), like many planes or many texture channels
c-cool) if really you go down this road, would be cool to see a preview of the layers and check the ones you want then press some "apply" button

As a reference I use xcftools to extract layers via shell script, have a look here
http://henning.makholm.net/software
http://henning.makholm.net/xcftools/

I hope I am posting this at the right place (usually I would post it in the 2.5 bug tracker? <- but since the script has its own 'Report a Bug' Button) but using the 'import Images as Planes' add-on doesn't work for me. Just nothing happens. I have used it before and it worked great but right now when I activate it in the user preferences and go to import, select an imagefile and load it, nothing happens. There's no plane (neither mesh nor object, no image).

My system configuration:
MacBook White
2,2 GHz Intel Core 2 Duo
2GB RAM
Intel GMA x3100
Snow Leopard 10.6.4

Blender rev. 31653 64bit Mac

thanks in advance.

hi, confirming error with svn 31984
updating to match svn script
thanks

Image loading works again, thanks.
I just can't use neither .MOVs nor AVI files but image-plane importing seems to work flawlessly.

From 2.5x tracker:
https://projects.blender.org/tracker/index.php?func=detail&aid=24609&group_id=9&atid=498

Import Images as Planes Doesn't work properly when using "use alpha" option
---
The Import images as Planes addon works fine, and when you use it, it brings up the file browser with a number of different
options, including an option to set the material to use the alpha of the image you're importing. This works find, and
it sets the image mapping settings to use the alpha of the image, but it doesn't set the influence of the image texture
to be alpha enabled, which means that the image doesn't appear until you do it manually. See the picture for more info.

From 2.5x tracker:
https://projects.blender.org/tracker/index.php?func=detail&aid=24609&group_id=9&atid=498

Import Images as Planes Doesn't work properly when using "use alpha" option
---
The Import images as Planes addon works fine, and when you use it, it brings up the file browser with a number of different
options, including an option to set the material to use the alpha of the image you're importing. This works find, and
it sets the image mapping settings to use the alpha of the image, but it doesn't set the influence of the image texture
to be alpha enabled, which means that the image doesn't appear until you do it manually. See the picture for more info.

Hi,
i made a little patch for the "Import Images as Planes Doesn't work properly when using "use alpha" option" bug :
http://www.pasteall.org/16823
cherrs
O

Hi!
Since your script is now in bf-extensions\' svn (contrib|trunk) we have deleted the current attachments to avoid that end-users could reach this page and get the wrong version of your script.
Note that your script may have api changes or small maintenence changes applied in SVN.
Please retrieve your script from SVN before updating SVN to avoid mis-versioned scripts.
Thanks!

Atom uploaded a patch on blenderartists.org which adds some additional functionality (read the whole thing here: http://blenderartists.org/forum/showthread.php?220247-AddOn-Import-Images-As-Planes-Script-Update-2.57-r3700), I've reviewed the script and removed all the useless stuff. I've attached the diff, so you can decide whether you want the additional functionality (in part or in whole) or not.

I have added a couple new features and fixed a bug I found in this AddOn.
A vimeo review here:http://vimeo.com/24443055

I recently did a project and used the io_import_images_as_planes.py script to import a lot of assets. Most of my assets were silhouettes so I had to do a lot of fixup on the materials after import to get everything the way I wanted it.

I consolidated all that fixup into a checkbox in this new version of the import script. So if you know you are importing silhouettes turn on the checkbox and it will do a few extra tasks to each material. Like turn on transparent shadow reception, turn off color mapping, add balanced emit/ambient values to the material and turn off specular highlights.

I also fixed a crash that occurs if you import images with Mac OSX hidden files on a Windows PC. The code now examines the width and height of each image. If the values are greater than zero the code allows processing, otherwise it skips that non-image found file on folder input.

A new feature I added is called Limit Display. In After Effects when you add an image to your composition it will only exist across a certain frame range. When this checkbox is active, each image in the folder will only exist for the duration amount in the scene. The code automatically animates the hide_render attribute of the imported image plane. So the first image will exist from frame #0-90, the second from frame 91-180 etc... This makes the Dope Sheet look like the After Effects layer window.

Another fix is I changed the default for Use image dimensions to be on instead of off. I always want my imported image to be the size of the image I am loading.

Sorry for the double post, this system is confusing.

I have added a couple new features and fixed a bug I found in this AddOn.
A vimeo review here:http://vimeo.com/24443055

I recently did a project and used the io_import_images_as_planes.py script to import a lot of assets. Most of my assets were silhouettes so I had to do a lot of fixup on the materials after import to get everything the way I wanted it.

I consolidated all that fixup into a checkbox in this new version of the import script. So if you know you are importing silhouettes turn on the checkbox and it will do a few extra tasks to each material. Like turn on transparent shadow reception, turn off color mapping, add balanced emit/ambient values to the material and turn off specular highlights.

I also fixed a crash that occurs if you import images with Mac OSX hidden files on a Windows PC. The code now examines the width and height of each image. If the values are greater than zero the code allows processing, otherwise it skips that non-image found file on folder input.

A new feature I added is called Limit Display. In After Effects when you add an image to your composition it will only exist across a certain frame range. When this checkbox is active, each image in the folder will only exist for the duration amount in the scene. The code automatically animates the hide_render attribute of the imported image plane. So the first image will exist from frame #0-90, the second from frame 91-180 etc... This makes the Dope Sheet look like the After Effects layer window.

Another fix is I changed the default for Use image dimensions to be on instead of off. I always want my imported image to be the size of the image I am loading.

I guess Jonathan beat me to it.

I did not notice his post was for my fix.

Another posting faux pas...

I like the add-on very much.

However I use it for the game engine and then I get bad results for opaque images because the texture-face settings are not properly set. It is always "Two Side" (performance) and Transparency: is always set to Alpha which causes terrible sorting effects when using the planes in a "game".



Hi,
Due to changes to the api including the merging of bmesh, several addons are outdated.
Please, if you are the author of an addon check your script with blender revision 44256 or newer.
That is builds made After blender 2.62 official release.
I would ask that updates be made to your addon before the Blender 2.63 release.
6-8 weeks away.
This allows time for the api to become more exposed & bmesh to stablize furthur.
If you need help, drop into irc freenode #blenderpython or #blendercoders & feel welcome to ask questions.
At the time of 2.63 release, scripts that are not repaired or in active developement will have their tracker page marked "Closed"
this will not affect your links to the tracker, similar to closing scripts in 2.49b, the page will be still availible & can be re-opened.

Thanks for your understanding & patience during these Exciting Times.
Brendon.

Hi Florian, I attached a modified version of this tool I’ve been working on those weeks (both diff and new version are in the tar.bz2)…

This wonderful tools suffered one annoying bug from my POV: it failed to import video files like .mkv or .mpeg! The problem in fact is in how files are checked, even with the “all” option if ext is not in the list, it is rejected… :/ So the main feature change of the patch is using much more intensively Blender’s file selector, to allow every image/movie format recognized by Blender when All option is chosen, and only show relevant files when another file type is selected.

In addition, I made some style cleanup (using keyword self outside of methods is not good practice) and a few refactoring.

Please let me know what you think of it (if you are OK, I’ll commit it ;) ), and thanks for this must-have addon!

Can you change the bl_idname of your operator. It is unusable with the imoort python keyword in the name if you wish to call it using bpy.ops.import.images_as_planes(..) as it will throw a syntax error.

can I suggest

bl_idname = "import_image.to_plane"

This is the only edit required.

Good point! Thanks for the report, committed as r3661.

Is this still working on trunk? i'm getting this error:

###########
RNA Warning: Current value "0" matches no enum in 'IMPORT_OT_image_to_plane', '(null)', 'extension'
RNA Warning: Current value "0" matches no enum in 'IMPORT_OT_image_to_plane', '(null)', 'extension'
Traceback (most recent call last):
File "/Users/dfelinto/blender/release/bin/blender.app/Contents/MacOS/2.63/scripts/addons/io_import_images_as_planes.py", line 326, in invoke
self.update_extensions(context)
File "/Users/dfelinto/blender/release/bin/blender.app/Contents/MacOS/2.63/scripts/addons/io_import_images_as_planes.py", line 212, in update_extensions
for e in EXT_FILTER[self.extension][0]))
KeyError: ''

location:<unknown location>:-1
#######

Hi,
I posted a modification on Blenderartist, and Batfinger told me to submit it here. So i attached it.
It allows to give the resolution in DPI. I use scanned grass, leaves, etc... a lot and it was really helpful for me to directly have the real world size in blender.
So i thought i would make it available for all.
It's a really small modification, but it saved me hours of work :)

Hi Mat, committed a (slightly different) version of this patch. Thanks for the code & idea! :)

you are welcome :) and i'm happy if i can see how you did it to learn from it :)

Hi guys,

I'm getting an error message since the last two builds. I'm using it in my recent project and it's kinda nasty to do it manual from scratch.
The error is:
Traceback (most recent call last):
File "/usr/share/blender/2.66/scripts/addons/io_import_images_as_planes.py", line 324, in execute
self.import_images(context)
File "/usr/share/blender/2.66/scripts/addons/io_import_images_as_planes.py", line 347, in import_images
planes = tuple(self.create_image_plane(context, mat) for mat in materials)
File "/usr/share/blender/2.66/scripts/addons/io_import_images_as_planes.py", line 347, in <genexpr>
planes = tuple(self.create_image_plane(context, mat) for mat in materials)
File "/usr/share/blender/2.66/scripts/addons/io_import_images_as_planes.py", line 345, in <genexpr>
materials = (self.create_cycles_material(img) for img in images)
File "/usr/share/blender/2.66/scripts/addons/io_import_images_as_planes.py", line 502, in create_cycles_material
bsdf_diffuse = node_tree.nodes.new('BSDF_DIFFUSE')
RuntimeError: Error: Node type BSDF_DIFFUSE undefined


location: <unknown location>:-1

Anyone the same problem?

{
Ubuntu 12.10
Kernel 3.7.8-030708-generic
GTX 660
NVIDIA Driver 3.13.26
}

Fixed in r4442, thx for the report! :)

(Was caused by recent merge of py nodes, which made some changes to nodes API ;) ).

:) yeah. Thank you very much and happy easter! :)

I'm developing an addon that manipulates the vertices in a plane.
I move each vertex by its index.
So far I've been working with standard planes added with Add>Mesh>Plane.
People are most likely going to use it with 'Import Images as Planes' since that provides an unwrapped textured plane.

The problem I'm having is, the index values for the vertex positions with this addon are not consistent with Add>Mesh>Plane.
Viewed from 'Top' view, an Add>Mesh>Plane has the following index values for the vertices: CW from upper left: 3, 2, 0, 1
But 'Import Images as Planes' creates the following: CW from upper left: 3, 2, 1, 0
These two ways of adding planes should match.

To correct this, the following:
verts = ((-x, -y, 0.0),
(+x, -y, 0.0),
(+x, +y, 0.0),
(-x, +y, 0.0),
)
faces = ((0, 1, 2, 3), )


Needs to be changed to this:
verts = ((+x, -y, 0.0),
(-x, -y, 0.0),
(+x, +y, 0.0),
(-x, +y, 0.0),
)
faces = ((1, 0, 2, 3), )

This change both creates vertices with matching index values to Add>Mesh>Plane, and also insures that the images are unwrapped and displayed properly.

Could someone make this correction please?

Thanks.



Done (though using a different solution ;) ). Thanks for the report.

When in Blender Game mode, I try to add an image(jpg, png, bmp, same result) and get the following error(although showing in reverse order from what was copy-pasted):

Traceback (most recent call last):
File "C:\Program Files\Blender Foundation\Blender\2.67\scripts\addons\io_import_images_as_planes.py", line 324, in execute
self.import_images(context)
File "C:\Program Files\Blender Foundation\Blender\2.67\scripts\addons\io_import_images_as_planes.py", line 347, in import_images
planes = tuple(self.create_image_plane(context, mat) for mat in materials)
UnboundLocalError: local variable 'materials' referenced before assignment

location: <unknown location>:-1


No image gets inserted. Works fine in Blender Render and Cycles Render, though.
Blender 2.67b on Windows 7.

Should be fixed now (r4576), thanks for the report. :)

Thanks for the quick fix! Works as expected.

On Windows, there seems to be an issue when you have saved your Blender file on one drive, but try to load an image from another:

location: <unknown location>:-1
Traceback (most recent call last):
File "C:\Program Files\Blender Foundation\Blender\2.68\scripts\addons\io_import_images_as_planes.py", line 323, in execute
self.import_images(context)
File "C:\Program Files\Blender Foundation\Blender\2.68\scripts\addons\io_import_images_as_planes.py", line 338, in import_images
self.set_image_options(img)
File "C:\Program Files\Blender Foundation\Blender\2.68\scripts\addons\io_import_images_as_planes.py", line 456, in set_image_options
image.filepath = bpy.path.relpath(image.filepath)
File "C:\Program Files\Blender Foundation\Blender\2.68\scripts\modules\bpy\path.py", line 104, in relpath
return "//" + _os.path.relpath(path, start)
File "C:\Program Files\Blender Foundation\Blender\2.68\python\lib\ntpath.py", line 622, in relpath
raise ValueError(error)
ValueError: path is on mount 'C:', start on mount 'D:'

This is easily solved by deselecting the "Relative" checkbox. I know this because I know how os.path.relpath works. However, others may not. A suggested solution is to uncheck + disable that checkbox when the paths are on different drives.

Hi, this has already been fixed (in r4635), but 2.68 was already tagged… ;)

Hi,
I am new here. I like the plugin "Import Images as Planes". It is a great help.
In earlyer Versions the naming for objects, materials, textures and meshes was derived from the image Name - that was a thing cool.
But unfortunately, in the last Version of Blender (2.69) it names all Planes "plane"+number.
I think, it would be vrey cool, if there where an Option to Chose the image-Name - or a free Name for the planes.

Best

PSD-Import doesn't work in Version 2.69.
Greetings

If I use an Image with smooth Alpha (like a Image , that Show a cloud), than the render is bad (artefakte). In other applications (Lightwave), I can use the same Image with his Alpha without Problems.

Added plane rename to texture.

PSD works here, note though that Blender can only import some kind of PSDs (those saved in compatibility mode, iirc)…

As for your alpha issue, I need the picture to test it!

Hi,
so quick answer - thank you.
If I try do Import psd-files, I do not see any psd in the list of files. I can write the Name of Image - then blender imports the Image - but Shows it not correctly.
Yes, I know, that I can rename the planes. But the Feature, that blender can use the names of the Images, was very cool (I tryed to Import many parts of a character, I want to animate in blender - 2D).
Can I upload Images?

See here: http://s14.directupload.net/file/d/3429/52y79kw7_png.htm
http://s7.directupload.net/file/d/3429/luh23yqk_png.htm
If you want, I send a psd-file.

Nah, by “image” I meant your texture with alpha, of course! Btw, you can attach them here (Attachments tab), just be sure to add a comment as well, else the tracker won’t accept your upload.

As for planes, I said I added plane rename in import script, so you have nothing else to bother about.

As for PSD, again, Blender can only import (in this script or anywhere in textures, nodes, Image Editor, etc.) some kind of PSDs, those saved with maximum compatibility setting in Photoshop iirc. Gimp's ones, e.g., do not load.
Not seeing PSD files in browser is strange, though, works OK here…

I have test it in cycles render - the smoothness transparence works here. But not in blender render, I think.

@Bastian,
You are very cool and quick. Thank you for the improvement with the names of planes.

Hi,
I am again.
A little thing, I do not understand: If I import some images as planes - it works fine. Alle planes have the same z-position.
Sometimes, I import the same images - one ore more have an other z-position as the other all. I is random, I think.
Greetings

This task was automatically closed as archived as part of migration, because it was determined to be no longer active.

The authoritative list of addons is on the wiki, we no longer have a report for each addon to track bugs and updates. Bugs can be reported individually and assigned to the addon developers. See the Addons project page for more information on the workflow.

Nobody (None) closed this task as Archived.Mar 25 2010, 6:22 AM

I have added a new feature to the Blender 2.7 Import Images As Planes.

When you import many images at once the resulting planes are placed in the scene stacking along the X axis. This new feature simply allows you to choose which axis you want the stacking to occur along. (X, Y or Z). It is a simple change and seems to work ok for Blender Internal or Cycles.

The BA thread is here.
http://www.blenderartists.org/forum/showthread.php?333722-Import-images-as-planes-addon-for-Z-axis&p=2631732&viewfull=1#post2631732

Hello!

I use this addon on my job every day and it rocks!
I have one question: Is it possible to make imge's path to be Relative? As it loads as absolute always. Even if the image is in the same place where the blend file.

Thanks.