Wikipedia:Reference desk/Archives/Computing/2025 January 4#Zoomify

Computing desk
< January 3 << Dec | January | Feb >> Current desk >
Welcome to the Wikipedia Computing Reference Desk Archives
The page you are currently viewing is a transcluded archive page. While you can leave answers for any questions shown below, please ask new questions on one of the current reference desk pages.


January 4

[edit]

Zoomify

[edit]

Is it possible to download the map La ligne de démarcation that is shown via Zoomify?--Antemister (talk) 22:48, 4 January 2025 (UTC)[reply]

Yes, if you google "download zoomify image" you will see various ways. Polygnotus (talk) 23:44, 4 January 2025 (UTC)[reply]
Ah, of course I googled before and found that but was not successful. So I asked here.--Antemister (talk) 11:31, 5 January 2025 (UTC)[reply]
Please mention what you've already tried before and what did not work and what happened instead (e.g. error messages). Polygnotus (talk) 04:57, 6 January 2025 (UTC)[reply]
Tried [1] and of course also the dezoomify tool but got immediately stuck because I was not able to find an URL. Very few programming skills, none regarding HTML, that's why I ask here.--Antemister (talk) 10:46, 6 January 2025 (UTC)[reply]
@Antemister:
I wasn't able to download the file as it was taking forever, but this URL appeared to download the files for 30+ minutes on a fast internet. Let us know if this works. TheTechie@enwiki (she/they | talk) 03:19, 8 January 2025 (UTC)[reply]
I've successfully taken images off the IWM via their source code and dezoomify, but I'm puzzled as to how to extract images here, as Dezoomify appears to be perpetually stuck on 'preparing tiles load'. The longest I've seen it take for large images in the past is a couple of minutes. Like Antemister, I've little programming knowledge, but I think the following elements in the code are related:
<script type="text/javascript" src="ZoomifyImageViewerFree-min.js"></script>
<script type="text/javascript"> Z.showImage("myContainer", "images/France_LD"); </script>
On going to http://cartesmich.free.fr/images/France_LD/ I get error 403. Perhaps this website is savvy about theft of its most high-resolution public domain images. Maybe someone has the patience to hunt about in the browser console. JayCubby 04:51, 8 January 2025 (UTC)[reply]
If they're public domain images, it's not "theft". Please avoid such misleading and perjorative language. Andy Mabbett (Pigsonthewing); Talk to Andy; Andy's edits 10:52, 8 January 2025 (UTC)[reply]
It's still potentially in violation of their ToS (not that I much care) and could, per my reading of my law (assuming this is an american website, which it isn't) run afoul of something like the Computer Fraud and Abuse Act.

The ToS is a reasonable concern, which is why I said theft. JayCubby 15:53, 8 January 2025 (UTC)[reply]
Even if all you say were true (It's highly doubtful; there appear to be no published terms of service - much less any that a user agrees to before viewing the site; and in any case we are not all in the USA), it's still not theft. Andy Mabbett (Pigsonthewing); Talk to Andy; Andy's edits 16:11, 8 January 2025 (UTC)[reply]
You're right--there are no terms (though the host website, free.fr, appears to have a TOS page). JayCubby 16:53, 8 January 2025 (UTC)[reply]

Yes, I came to that cited code, but had no idea to open that container Also tried again dezoomify, and also waited a long time, and after 1-2 hours i get an error message. And it includes a link, [2], if you alter the numbers you can find various tiles of the map.is it possible to proceed with that, download that folder?--Antemister (talk) 22:34, 8 January 2025 (UTC)[reply]

Hmm! So I pasted this conversation into ChatGPT, and told it to generate code for use in Google Colab. The code is here (it doesn't really do what it's supposed to, at all, but a start).
The really screwed-up image it generated is here. Hopefully these are of help to someone with more Python experience than I.JayCubby 02:35, 9 January 2025 (UTC)[reply]

I gave this another try. This time it was able to actually download the image correctly, but only a horizontal section. The code is collapsed below. I think it needs only some slight tweaking.

Extended content

import os ::import requests ::from PIL import Image ::# Base URL and directory setup ::BASE_URL = "http://cartesmich.free.fr/images/France_LD/TileGroup8/" ::OUTPUT_DIR = "tiles" ::MERGED_IMAGE = "merged_image.jpg" ::# Ensure the output directory exists ::os.makedirs(OUTPUT_DIR, exist_ok=True) ::# Function to download a tile ::def download_tile(url, save_path): :: response = requests.get(url) :: if response.status_code == 200: :: with open(save_path, "wb") as f: :: f.write(response.content) :: return True :: return False ::# Function to stitch the tiles together ::def stitch_tiles(tiles, tile_size): :: max_x = max(x for x, y in tiles.keys()) + 1 :: max_y = max(y for x, y in tiles.keys()) + 1 :: # Create a blank canvas for the final image :: merged_image = Image.new("RGB", (max_x * tile_size, max_y * tile_size)) :: # Paste tiles onto the canvas :: for (x, y), tile_path in tiles.items(): :: tile_image = Image.open(tile_path) :: merged_image.paste(tile_image, (x * tile_size, y * tile_size)) :: return merged_image ::# Set parameters for downloading tiles ::tile_size = 256 # Assume each tile is 256x256 ::x_range = range(36, 50) # Adjust based on your needs (x-coordinate range) ::y_range = range(24, 40) # Adjust based on your needs (y-coordinate range) ::# Dictionary to store downloaded tile paths ::downloaded_tiles = {} ::# Download tiles ::for x in x_range: :: for y in y_range: :: tile_url = f"{BASE_URL}6-{x}-{y}.jpg" :: tile_path = os.path.join(OUTPUT_DIR, f"6-{x}-{y}.jpg") :: if download_tile(tile_url, tile_path): :: downloaded_tiles[(x - min(x_range), y - min(y_range))] = tile_path :: print(f"Downloaded: {tile_url}") :: else: :: print(f"Tile not found: {tile_url}") ::# Stitch the tiles into a single image ::if downloaded_tiles: :: merged_image = stitch_tiles(downloaded_tiles, tile_size) :: merged_image.save(MERGED_IMAGE) :: print(f"Merged image saved as {MERGED_IMAGE}") ::else: :: print("No tiles were downloaded!")

-- JayCubby 16:09, 9 January 2025 (UTC)[reply]

Oh, again some progress! What horizontal slide? Maybe iterate through the TileGroup folders?--Antemister (talk) 16:56, 9 January 2025 (UTC)[reply]
User:Antemister, it was one of the bottom sections of the map, I have some silly 2FA on my devices and can't access the one I ran it on for a couple of hours. You should be able to run the above code in Colab and ask ChatGPT (or Gemini) for further help. JayCubby 17:02, 9 January 2025 (UTC)[reply]
First heard about Colab but tried, and it seems the Code does something. What is the Folder you got the files downlaoded?--Antemister (talk) 17:30, 9 January 2025 (UTC)[reply]

Antemister In a new cell, type from google.colab import files files.download('merged_image.jpg') Apologies for putting all of this inside a hat template, I can't figure out how to correct it. JayCubby 18:15, 9 January 2025 (UTC)[reply]

Again progress, have gotten such a merged image that shows a part of the map. The iteration is just a guess... Shouldnt there be a possibility to list all the files in the folder?--Antemister (talk) 22:58, 9 January 2025 (UTC)[reply]
@Antemister, I very nearly got it to work, the final image is 12,000x12,000px but has errors. import os
import requests
from PIL import Image
from concurrent.futures import ThreadPoolExecutor
  1. Base URL and output setup
BASE_URL = "http://cartesmich.free.fr/images/France_LD/"
OUTPUT_DIR = "tiles"
MERGED_IMAGE = "merged_image.jpg"
  1. Ensure output directory exists
os.makedirs(OUTPUT_DIR, exist_ok=True)
  1. Function to download a tile
def download_tile(group, x, y):
url = f"{BASE_URL}TileGroup{group}/6-{x}-{y}.jpg"
save_path = os.path.join(OUTPUT_DIR, f"TileGroup{group}_6-{x}-{y}.jpg")
try:
response = requests.get(url, timeout=10)
if response.status_code == 200:
with open(save_path, "wb") as f:
f.write(response.content)
print(f"Downloaded: {url}")
return (group, x, y, save_path)
else:
print(f"Tile not found: {url}")
except Exception as e:
print(f"Error downloading {url}: {e}")
return None
  1. Function to download all tiles (no detection, brute force)
def download_all_tiles(groups, x_range, y_range):
tiles = []
print("Starting brute force tile download...")
with ThreadPoolExecutor(max_workers=10) as executor:
futures = []
for group in groups:
for x in x_range:
for y in y_range:
futures.append(executor.submit(download_tile, group, x, y))
for future in futures:
result = future.result()
if result:
tiles.append(result)
return tiles
  1. Function to stitch tiles together
def stitch_tiles(tiles, tile_size):
if not tiles:
print("No tiles to stitch.")
return None
  1. Determine the range of x and y coordinates
all_coords = [(x, y) for _, x, y, _ in tiles]
min_x = min(x for x, y in all_coords)
max_x = max(x for x, y in all_coords)
min_y = min(y for x, y in all_coords)
max_y = max(y for x, y in all_coords)
  1. Create a blank canvas for the final image
width = (max_x - min_x + 1) * tile_size
height = (max_y - min_y + 1) * tile_size
merged_image = Image.new("RGB", (width, height))
  1. Paste tiles onto the canvas
for group, x, y, tile_path in tiles:
tile_image = Image.open(tile_path)
merged_image.paste(
tile_image, ((x - min_x) * tile_size, (y - min_y) * tile_size)
)
return merged_image
  1. Main script execution
tile_size = 256 # Assume each tile is 256x256
groups = range(0, 16) # TileGroup0 to TileGroup15
x_range = range(0, 50) # x-coordinates: 0–49
y_range = range(0, 50) # y-coordinates: 0–49
tiles = download_all_tiles(groups, x_range, y_range)
  1. Stitch the tiles into a single image
if tiles:
merged_image = stitch_tiles(tiles, tile_size)
if merged_image:
merged_image.save(MERGED_IMAGE)
print(f"Merged image saved as {MERGED_IMAGE}")
else:
print("No tiles were downloaded!") JayCubby 03:31, 11 January 2025 (UTC)[reply]
Here's the link. https://limewire.com/d/50995585-f881-4ff5-9186-e0eb55978a5e#Tcw-4kZBQKVH0GS9yZPb-vUvH8t-V04gV-t8MQp8O7k JayCubby 03:38, 11 January 2025 (UTC)[reply]
Thank you, that is sufficient, what I need is the ceasefire/demarcation line. Can you sent me the code with correct formatting? Maybe I can use it in future, to download other zoomified images.--Antemister (talk) 14:18, 11 January 2025 (UTC)[reply]
Here you are: https://pastebin.com/gPKrd1cj JayCubby 18:04, 11 January 2025 (UTC)[reply]