How to generate USDZ file again from ZIP file? - scenekit

Hello everyone I'm trying to unzip a USDZ file, modify a texture, and then zip the USDZ file again, but it breaks.
Is there any special way to zip the file back? Even if I decompress and compress again it stops working and has different file size.
I'm using no compression and no encryption to zip the file. One thing I have noticed is that the attribute "Needed to extract" for the USDZ file is "2.0 or later" while my new zip file value is "1.0 or later". Also the files in the original USDZ zip have some extra fields I cannot read or add to my new file.
What could be happening? Any help would be appreciated.

Unzip usdz file
To unzip a usdz file in macOS use the following steps (if you don't have Mac, use a Hackintosh):
In Finder change the extension of .usdz file to .zip.
Uncompress .zip file by double-clicking it.
Open unzipped directory and change the .png textures of your model.
Open and edit .aiff, .caf or mp3 audio files, if any.
You can even import a binary .usdc file in Maya 2023 for animation.
Create usdz file again
Make sure that the latest Xcode version is installed (now Xcode 14.0).
To convert a content of unzipped folder (binary usdc file and its textures) back to usdz file format again, use the following command in Terminal.app:
usdzconvert ~/Desktop/file.usdc -diffuseColor Grammophone_Albedo.png
-metallic Grammophone_Metallic.png
-occlusion Grammophone_AO.png
-normal Grammophone_Normal.png
-roughness Grammophone_Roughness.png
And here's an additional info about usdzconvert command for Xcode 14/13/12/11/10.

To pack my modified USDZ file back, I used the tools provided here: https://github.com/PixarAnimationStudios/USD (usdzip) which works in Windows and Linux.

Related

File format Error after Download - Jekyll blog

I would like users to download a zip file and I have the following code.
<a href="directory/fileName.zip" download>DOWNLOAD</a>
However, when I test it out, the file downloads instantly and when I try to open it, I get the unsupported format error. On localhost, it downloads instantly but the zip file successfully opens.
I am on MacOS and have git lfs installed if that is important. Any help would be greatly appreciated. Thank you.
I tried renaming the file so that there are no spaces in its name, tried to separately compress the directory to be zipped.

The file is not displayed in the editor because it is either binary or uses an unsupported text encoding

Is it related or not I don't know but when I install firebase and open VS Code again, this problem appeared in package.json and package-lock.json when click to 'Open anyway' button Text-Editor this nulnulnul issue come up
nul problem:
When I open package.json file with Hex Editor shown like this
with hex editor:
Edit:
I deleted package.json files and install all packages again and it works
just extract the files before you even open the zipped files in the vs code
Had similar experience and these are the steps I took.
If you've push the project to github or any source control system, copy the package.json file in the repo, delete the corrupted package.json file in the project folder, then paste the copied package.json file on your project folder.
I went through this problem
The cause of the problem was that I had the files in extension Example.rar
Then instead of extracting the files by decompressing them
I dragged it through a program window through
instead of extracting it naturally
I was using a system at the time ubuntu And I want to access the files through a program "vs code"
The program I was using is called "Archive Manager"
The Archive Manager in Ubuntu is a utility program that allows users to manage compressed archives, such as ZIP, TAR, RAR, GZIP, and BZIP
Solve the problem if you go through the same experience as me
Unzip the files normally
Then try to make sure the files are working

How to set correct path for opening pdf file by using programName.bat?

I am struggling with opening a PDF file as a user's documentation in JavaFX program.
Code works fine whenever I open it using IDE. The problem begins when I build my program and try to open it from distributions folder.
For example, this method works, when I am using IDE:
public void helpButtonOnAction(ActionEvent actionEvent) {
File file = new File("src/main/resources/pl/com/buleek/docs.pdf");
hostServices.showDocument(file.getAbsolutePath());
}
But obviously, when I pack my program with gradle build, it is in a directory:
C:\Users\Matthew\Desktop\xxx\ProgramNameFolder\build\distributions\ProgramName\bin
And from now on, it can't see src/main/recources/pl/com/buleek/docs.pdf, because in ProgramNameFolder there are only bin with ProgramName.bat and lib folders.
Is there a way (after building distributions) to paste another folder inside my ProgramName folder, put there my docs.pdf file, and then set code like:
public void helpButtonOnAction(ActionEvent actionEvent) {
File file = new File("ProgramName/docs/docs.pdf");
hostServices.showDocument(file.getAbsolutePath());
}
Or shall I use some command to pack pdf file with my program?
Your build tool will usually place your resources in a jar. As your PDF file is already in your resources folder, it should be packaged into your application jar by default.
You can read resources from your jar file via YourClass.class.getResourceAsStream(), then write the stream to a temp file using basic Java I/O APIs, specifically the version of Files.copy(...) which takes an input stream as a parameter.
The intermediate step of extracting the PDF file from your jar and writing to a temp file in the file system is necessary because you are using host services to launch an external browser and, unlike java, the external browser will be unable to directly read resources from a jar file.
You can convert the file name of the temporary file to a URL string and show it via HostServices.showDocument(uri) as you are currently doing.
If the browser is capable of displaying PDFs (most are) then the PDF will be displayed in the browser, otherwise, the browser will usually allow the user to download the PDF to a file location of their choice on their machine and open the PDF via an external application.

Download a public file in Bitrise Workflow

I have my zip uploaded on Gofile, and using the direct download link I'm trying to use CURL in my step to download it on my build.
Even if the step work, the file is not totally donwloaded as I can't unzip it..
+ curl https://srv-store3.gofile.io/download/RIDfRD/xxxx.zip -o xxxx.zip
here is the command I used
I have no idea why this don't download. I also tried the "official" download step
Are you receiving the following error when trying to unzip it?
End-of-central-directory signature not found. Either this file is not
a zipfile, or it constitutes one disk of a multi-part archive. In the
latter case the central directory and zipfile comment will be found on
the last disk(s) of this archive.
This means the zip file is corrupted. I was able to reproduce it with my own file. Go file is intended to be downloaded from the website not through curl.
I would recommend using a different service like https://gist.github.com and copying the raw file link and using that in the curl command.

How to upload folders to Google Colab?

I want to run a notebook that uses many header files defined in the directory. So basically I want to upload the entire directory to Google Colab so that I can run the notebook. But I am unable to find any such options and only able to upload files not complete folders. So can someone tell me how to upload entire directory to google colab?
I suggest you not to upload them just in Colab, since when you're restarting the runtime you will lose them (just need to re-upload them, but it can be an issue with slow connections).
I suggest you to use the google.colab package to manage files and folders in Colab. Just upload everything you need to your google drive, then import:
from google.colab import drive
drive.mount('/content/gdrive')
In this way, you just need to login to your google account through google authentication API, and you can use files/folders as if they were uploaded on Colab.
EDIT May 2022:
As pointed out in the comments, using Google Drive as storage for a large number of files to train a model is painfully slow, as described here: Google Colab is very slow compared to my PC. The better solution in this case is to zip the files, upload them to colab and then unzip them using
!unzip file.zip
More unzip options here: https://linux.die.net/man/1/unzip
You can zip them, upload, then unzip it.
!unzip file.zip
The easiest way to do this, if the folder/file is on your local drive:
Compress the folder into a ZIP file.
Upload the zipped file into colab using the upload button in the File section. Yes, there is a File section, see the left side of the colab screen.
Use this line of code to extract the file. Note: The file path is from colab's File section.
from zipfile import ZipFile
file_name = file_path
with ZipFile(file_name, 'r') as zip:
zip.extractall()
print('Done')
Click Refresh in the colab File section.
Access the files in your folder through the file paths
Downside: The files will be deleted after the runtime is over.
You can use some part of these steps if your file is on a Google Drive, just upload the zipped file to colab from Google Drive.
you can create a git repository and push the files and folders to it,
and then can clone the repository in colaboratory with the command
!git clone https://github.com/{username}/{projectname}.git
i feel this method is faster.
but if the file size is more than 100 mb you will have to zip the file or will have to add extentions to push it to github.
for more information refer the link below.
https://help.github.com/en/github/managing-large-files/configuring-git-large-file-storage
The best way to approach this problem is simple yet tricky sometimes.
You first need to compress the folder into a zipped file and upload the same into your google drive.
While doing so, Make sure that the folder is in the root directory of the drive and not in any other subfolder!. If the compressed folder/data is in other subfolder, you can easily move the same into the root directory.
Compresses folder/data in another subfolder often messes with the unzipping process when you will be specifying the file location.
Once you did the afore mentioned tasks, enter the following commands in the colab to mount your drive:
from google.colab import drive
drive.mount('/content/gdrive')
This will ask for an access token that can be generated by clicking on the url displayed in the output of the same cell
!ls gdrive/MyDrive
Check the contents of the drive by executing the above command and ensure that your folder/data is displayed in the output.
!unzip gdrive/MyDrive/<File_name_without_space>.zip
eg:
!unzip gdrive/MyDrive/data_folder.zip
Executing the same will start unzipping your folder into the memory.
Congrats! You have successfully uploaded your folder/data into the colab.
zip your files zip -r file.zip your_folder and then:
from google.colab import files
from zipfile import ZipFile
with ZipFile(files.upload(), 'r') as zip:
zip.extractall()
print('Done')
So here's what you can do:
-upload the dataset desired folder to your drive
-over colab, mount the drive wherein this
"from google.colab import drive
drive.mount('/content/gdrive')"
automatically shows up and you just need to run it
-then check for your file over the Files section on the left-hand side (if folder not visible try refreshing, also there should be a drop-down arrow next to it where you can check all the files under the folder )
-left-click over the folder wherein you get a COPY PATH option
-paste the copied path over the desired location in your colab

Resources