Open gh-vicentiu opened 2 years ago
@gh-vicentiu could you elaborate?
Is the metadata in the json files generated by hashlips or is it in the images?
Hi, the metadata is generated by hashlips, wanted to paste a json file here but it's a mess so i will try to explain.
So i have a number of folders with layers inside lets say 3:
Folder1: (contains image layers) layer1 layer2 layer3
Folder2: (contains shape layers) layer1 layer2 layer3
I've just looked up, Photoshop limits the name of the layers to 64 characters. So, what i would like to do, is pull the text from inside the layer, not the text from the layer's name, and use it as description.
i hope it's a bit more clear.
@gh-vicentiu
wanted to paste a json file here but it's a mess
Could you paste it within backticks:
pull the text from inside the layer
What do you mean by this?
this is the collection i'm working out, maybe it will help, i hope there si no problem posting it. i've uploaded it without metadata since i'm trying to figure out how these things work
so what i want is to use that quote in the description, ideal would be to do some regex and pull the author of the quote as metadata and use the entrie thing as description but i guess that's a bit to much.
also i find it an issue that hashlips can't work with cascade directory format :\ but that's ok
ok, sry for the mess, the metadata names and all that is a mess:
{"name":"Little Buddha Quotes NFT #2","description":"Little Buddha Quotes","image":"2","edition":2,"attributes":[{"trait_type":"nose","value":"Layer 118"},{"trait_type":"mouths","value":"Layer 146"},{"trait_type":"3rd eye","value":"Layer 63"},{"trait_type":"eyes","value":"Layer 84"},{"trait_type":"head shapes","value":"Ellipse 4 copy 2"},{"trait_type":"ears","value":"Layer 121 copy"},{"trait_type":"filters","value":"Layer 151"},{"trait_type":"body color","value":"Layer 121 copy 4"},{"trait_type":"body","value":"Layer 45 copy"},{"trait_type":"quotes","value":"“Radiate boundless love towards the entire world.” Gautama Bu"},{"trait_type":"circle patterns","value":"Layer 144 copy 3"},{"trait_type":"mandala 4","value":"Layer 99"},{"trait_type":"mandala 3","value":"Layer 98"},{"trait_type":"mandala 2","value":"Layer 107"},{"trait_type":"mandala 1","value":"Layer 175"},{"trait_type":"NFT","value":"NFT copy"},{"trait_type":"effects circles","value":"Layer 117 copy 2"},{"trait_type":"circles 3","value":"Ellipse 1 copy 5"},{"trait_type":"circles 2","value":"Ellipse 1 copy 2"},{"trait_type":"circles 1","value":"Ellipse 1 copy 11"},{"trait_type":"background","value":"Rectangle 3 copy 2"}]}
{"trait_type":"quotes","value":"“Radiate boundless love towards the entire world.” Gautama Bu"} it cuts out before the actual text ends. because that's the name of the layer, not the text inside the layer
this is the quote: ”If you seek peace, be still. If you seek wisdom, be silent. If you seek love, be yourself.”
Becca Lee
this is the name of the layer: ”If you seek peace, be still. If you seek wisdom, be silent.
@gh-vicentiu If you only have one layer config you could use something like (pseudocode):
description: edition.attributes[9];
What command are you using to upload them?
i tried a few things to upload but had issues with those before i found this:
@gh-vicentiu if that loads the descriptions from the description
attribute of the json files, you could try running this js code:
const basePath = process.cwd();
const fs = require("fs");
let rawdata = fs.readFileSync(`${basePath}/build/json/_metadata.json`);
let data = JSON.parse(rawdata);
data.forEach((item) => {
item.description = item.attributes.find(a => a.trait_type == "quotes").value;
fs.writeFileSync(
`${basePath}/build/json/${item.edition}.json`,
JSON.stringify(item, null, 2)
);
});
fs.writeFileSync(
`${basePath}/build/json/_metadata.json`,
JSON.stringify(data, null, 2)
);
`def save():
if len(start_num_input.input_field.get()) == 0 or len(end_num_input.input_field.get()) == 0 or (int(end_num_input.input_field.get()) < int(start_num_input.input_field.get())):
#messagebox.showwarning("showwarning", "End number should greater than start number!")
print ("true")
elif len( start_num_input.input_field.get()) == 0 or len(end_num_input.input_field.get()) > 5 :
#messagebox.showwarning("showwarning", "Start / end number range 0 - 99999")
print ("true")
else:
collection_link_input.validate_inputs(200, 2, 'Collection link required')
price.validate_inputs(100, 1, 'Price required')
title.validate_inputs(100, 2, 'title required')
description.validate_inputs(200, 2, 'description required')
file_format.validate_inputs(100, 2, 'file format required - png, jpg, jpeg')
external_link.validate_inputs(100, 3, '')
input_save_list.insert(0, upload_path)
collection_link_input.save_inputs(1)
start_num_input.save_inputs(2)
end_num_input.save_inputs(3)
price.save_inputs(4)
title.save_inputs(5)
description.save_inputs(6)
file_format.save_inputs(7)
external_link.save_inputs(8)
def main_program_loop():
if len(end_num_input.input_field.get()) > 5 :
messagebox.showwarning("showwarning", "Start / end number range 0 - 99999")
sys.exit()
project_path = main_directory
file_path = upload_path
collection_link = collection_link_input.input_field.get()
start_num = int(start_num_input.input_field.get())
end_num = int(end_num_input.input_field.get())
loop_price = float(price.input_field.get())
loop_title = title.input_field.get()
loop_file_format = file_format.input_field.get()
loop_external_link = str(external_link.input_field.get())
loop_description = `description.input_field.get()``
it gets description from the form input. If i understand the above code correctly here is where i should change
loop_description =
description.input_field.get()``
maybe define description as a different word so i won't need to rewrite everything?
@gh-vicentiu It would probably be on this line
@gh-vicentiu you could replace the line I linked with this:
desc.send_keys(json.loads(open(file_path + "\\json\\"+ str(start_numformat) + ".json").read())["attributes"][9])
Note: it presumes that the quote is always layer 10. If it's not always that layer I could make something but it would be more complicated.
It's also not awfully efficient, but it should do.
Hello, i would like to pull the metadata description from the layers i have into a folder named quotes.
When the scrip runs by default, it also truncates the text, some layers have long names as they are quotes... I've just checked out, Photoshop is actually the one shortening the text from the layer.
Still the first question remains, maybe you have an idea for the second issue as well. Is there a way to pull the text directly from the text layer and not the name of the layer?