Giter Club home page Giter Club logo

Comments (3)

Irmitya avatar Irmitya commented on July 23, 2024 1

I already have the code setup for extraction.
I just got stopped at the file things because the name of one of my files had at least one illegal character ?, and while I could just swap/remove all illegal characters \:*?"<>|, I could probably break something if the character was relevant to the file's location rather than name.

I'm not in a hurry to do anything; I need to have code/scripts ready with a new process validated to migrate from what I currently do.

My first goal is to detach images from .pur files, so that I can access/change the files elsewhere, as well as stop it from taking so long to save (dozens-of-seconds to several-minutes).
My second goal is to be able to run a script to autoupdate text on my bookmarks....which while I was testing, I found a problem #3 that makes the first task more cumbersome and the second non-viable.

from pureref-format.

FyorDev avatar FyorDev commented on July 23, 2024

I've just realized I never took local images into account in the case of the 'embed local images in save file' setting in PureRef being turned off. Meaning the image is not packed and saved but only linked in the file, an option I've always had on and didn't consider.
I'll add functionality for this in a while, next week after exams. If this is indeed the issue, you can circumvent this for now by saving the file (I'd suggest under a different name) with the 'embed local images in save file' setting in PureRef turned on. Be sure to turn it off again to avoid unlinking your other files upon saving.

For files with packed images, this piece of code extracts an image from a PureRef file.

import purformat
from PIL import Image
import io

purobj = purformat.PurFile()
purobj.read("NewScene.pur")
img = purobj.images[0]

Image.open(io.BytesIO(img.pngBinary)).save(fR"{img.transforms[0].name}.png")

If this doesn't work for you I'd like to have a file that has this issue so I can fix it.

About nested folders and duplicate filenames, this depends entirely on how you handle file saving. If you save different images with the same name in the same place they would be overwritten. If this is an issue you could check if the file already exists or use the PurGraphicsImageItem source.

from pureref-format.

FyorDev avatar FyorDev commented on July 23, 2024

I'm aware this was not the original issue, but unpacked external image links are now supported since 3b680e6. External image links have 0xFFFFFFFF as the binary and the source is used as the link. You can now read and write a file while retaining links, or add new images with links yourself.

from pureref-format.

Related Issues (5)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.