# Download/Decompress an archive and display images

**URL:** <https://scilab.discourse.group/t/download-decompress-an-archive-and-display-images/861>\
**Category:** General usage\
**Created:** [March 13, 2025, 8:34am UTC](https://scilab.discourse.group/t/download-decompress-an-archive-and-display-images/861 "2025-03-13T08:34:58Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![cedric.delamarre](https://avatars.discourse-cdn.com/v4/letter/c/49beb7/32.png) [@cedric.delamarre](https://scilab.discourse.group/u/cedric.delamarre)\
**Post date:** [March 13, 2025, 8:34am UTC](https://scilab.discourse.group/t/download-decompress-an-archive-and-display-images/861/1 "2025-03-13T08:34:58Z")

</div>

Did you know you can directly decompress an archive using Scilab?

Here is an example that downloads an archive using [http\_get](https://help.scilab.org/http_get.html), [decompresses](https://help.scilab.org/decompress.html) it, and displays its contents (images) in an [uicontrol](https://help.scilab.org/uicontrol.html).

### Download

We first download the archive. This example is based on a `zip` file but many other formats are managed.

```auto
// URL of a zip file
zipUrl = "https://gitlab.com/scilab/forge/scicv/-/archive/0.6.2/scicv-0.6.2.zip?path=data/images";

// Download the zip file
mprintf("Downloading archive file... ");
zipFile = http_get(zipUrl, "output_images.zip");
mprintf("DONE\n");

```

### Decompress

Then we extract its contents in a specific directory:

```auto
// Extract the archive and return the list of extracted element path
mprintf("Decompressing archive... ");
extracted = decompress("output_images.zip", "output_dir");

// Keep only files from the decompressed extracted element list
names = fileparts(extracted, 'fname');
fileIdx = find(names <> "");
files = extracted(fileIdx);
filenames = names(fileIdx);
mprintf("%d files extracted.\n", size(files, "*"));

```

### Display

And finally, we display the extracted images in a `uicontrol` based GUI:

```auto
// Create the main figure
f = figure("name", "Image browser", "background", -2, "axes_size", [700, 350], "tag", "main_figure", "toolbar_visible", "off", "menubar_visible", "off");

// Display selectable file list
uicontrol(f, "style", "listbox", "string", filenames, "userdata", files, "position", [20, 20, 200, 300], "callback", "image_changes_cb");

// Add a label above the file list
uicontrol(f, "style", "text", "string", " Extracted images:", "BackgroundColor", [1,1,1], "position", [20, 325, 200, 20], "FontWeight", "bold");

// Display the image after clicking on the image name
uicontrol(f, "style", "image", "BackgroundColor", [1,1,1], "horizontalalignment", "center", "verticalalignment", "middle", "Position", [250, 20, 400, 300], "tag", "image_zone");

// Defines the callback function called when clicking on a filename
function image_changes_cb()
    selectedFile = gcbo().userdata(gcbo().value);
    set("image_zone", "String", selectedFile);
    set("main_figure", "info_message", pathconvert(selectedFile));
endfunction

```

 ![post_03_2025_gui](https://global.discourse-cdn.com/free1/uploads/utc/original/1X/5c519f80f3fb63bb9844e8d2172edfda27e474da.png)

Feel free to use this example as a basis for your own demo 🙂

---

<div class="post-metadata">

**Author:** ![fmiyara](https://avatars.discourse-cdn.com/v4/letter/f/e68b1a/32.png) [@fmiyara](https://scilab.discourse.group/u/fmiyara)\
**Post date:** [March 15, 2025, 4:31am UTC](https://scilab.discourse.group/t/download-decompress-an-archive-and-display-images/861/2 "2025-03-15T04:31:16Z")

</div>

Excellent! I didn’t even know Scilab could display images directly without having to express them as a 2D function and use a gigantic colormap. Terrific!

Thank you!

Regards,

Federico Miyara

---

<div class="post-metadata">

**Author:** ![mottelet](https://yyz2.discourse-cdn.com/free1/user_avatar/scilab.discourse.group/mottelet/32/13_2.png) [@mottelet](https://scilab.discourse.group/u/mottelet)\
**Post date:** [March 15, 2025, 9:04pm UTC](https://scilab.discourse.group/t/download-decompress-an-archive-and-display-images/861/3 "2025-03-15T21:04:27Z")

</div>

> [@fmiyara](#):
>
> Scilab could display images directly

Matplot can display TrueColor (hence not needing a colormap) images since Scilab 5.5.0 (but reading the image has to be done using imread from IPCV or scicv).

S.
