Example Code

Read GIF File

Code and Documents

Attachment

This example was first published in the LabVIEW Forum, but i want to publish also a LabVIEW 7.1 version.

gif.PNG

The additional input "image index" is used to select the image, which should be available at the image data output.

Currently it supports only gif files with version 89a.

Interlaced images are not taken into account.

The vi inside of the "Read GIF File" function can also be used to read all images of a Gif file. More about how to use it can be seen in the GIF._Example.vi which is also part of the attached zip file.

Version 01.01

- first image is now index 0

Example code from the Example Code Exchange in the NI Community is licensed with the MIT license.

Comments
Todd S.
NI Employee
on

Thanks for posting this!

Todd S.
LabVIEW Community Manager
National Instruments
Thoric
Trusted Enthusiast Trusted Enthusiast
Trusted Enthusiast
on

Astonishing amount of work in this - especially the LZW decoder! Respect.

Thoric (CLA, CLED, CTD and LabVIEW Champion)


manfroe
Member
Member
on

Nice work, but I get an error if I try to read a file a second time. Analysing your code I found out, that you don't close the .gif-file in the Gif.Main.vi.

Nevertheless I'm glad to use the code.

_Xilinx_
Member
Member
on

Thanks for sharing, nice piece of Code!

I was trying the Gif.Main.vi but it always give me an Array of 1 Image and not all images in the Gif,Clipboard01.gif

I will try to figure out how to extract the other images so they can be played in a vi.

MikeS81
Proven Zealot
Proven Zealot
on

Hi _Xilinx_,

just change the image index on the front panel to "-1" to read all images.

Mike

viScience
Active Participant
Active Participant
on

Amazing wireworking gem, thanks for sharing with us!

Swinders
Member
Member
on

 

Gif.Main.vi[readfile].PNG Great work, as has been noted above loading a file for the second time will return an error due to the file reference being locked from a previous read. The solution is to open the Gif.Main.vi and select the "readfile" case. Add a 'Close File.vi' from the 'File I/O' function palette. 

Steve Swindley (CLA since Feb 2008)
GCentral
nlhnt
Member
Member
on

Hey I've forked this on github, just letting you know.

 

Gave the credits in LICENSE and in Readme.


https://github.com/nlhnt/lv_gif_tricks

Researcher @ Gdańsk University of Technology
Contributors