File size not reducing after compressing - zip

In my laptop, whenever i try to compress any file (doc, docx, pdf, jpg, etc etc) using 7zip or any other software, the size of compressed file remains the same as original file. I set the correct setting but still it's same.
Some say that the file can't be compressed anymore and try to compress other file but i tested all my files in my laptop and none of those files are getting reduced in size after compression.

Not sure about .doc, but .docx, .pdf. and .jpg are all already compressed. Something that's already compressed looks like random bits to a compressor, and so can't be compressed. In fact, they will be expanded very slightly. The only way to compress those is to first decompress them, and then recompress them with something that's more effective. Assuming that you can find something that's more effective.

Related

Node.js (fs) not correctly reading/processing image files, changing source code (codesandbox example)

I am faced with the challenge to read a (png) file with Node.js fs package correctly.
BACKGROUND
I am writing a program to analyze files, here png, in-depth.
PNG image files are made of several differently named chunks. One of them is called IDAT.
Nearly each PNG is made of many IDAT chunks.
You can simply read and find all of them if you right click a png file in Windows and open it with Notepad, WordPad, etc.
EXAMPLE To make it clearer and more descriptive, I have prepared it all in https://codesandbox.io/s/node-image-buffer-bntv4x
PROBLEM Node.js with fs package in the codesandbox example above does not correctly read (fs.readFileSync) the
original image called 'reactOriginal.png'. Composition and code structure are changed.
When node reads 'reactOriginal.png', it
provides a UTF8 output in the codesandbox example, which is printed in the right browser window. You can search and find the IDAT chunk
exactly one time. This is wrong, the source code is corrupted.
You can convince yourself and download and check 'reactOriginal.png' in files folder which is read by fs.readFileSync.
The original has a very different composition, for example there are 5 IDAT chunks (but even more has changed).
The copy of the corrupted source code called 'reactCopy.png' is still correctly displayed when opened but the entire content is
totally, rearranged, reordered, changed, etc. I need the original to inspect it.
OBSERVATIONS To my point of view, Node.js or fs package is causing this corruption. The cause cannot be codesandbox as the uploaded and, again, downloaded 'reactOriginal.png' remains the same / unchanged.
I also tried alternative libraries, such as fs-extra or graceful-fs. Nothing changed relating to the corrupted output.
I checked 5 different png files. Everywhere the same issue. Large png files with more than 20 IDAT chunks are converted and printed with one IDAT chunk (and many other parts changed, too).
What is wrong? Is there a problem with Node's fs package?
More important: How can I get/read the exact, not corrupted but correct source code of a file?
I hope somebody can help me in this case.

Compress Decompressed Exe File

So, I decompressed an exe file and modified it, and I want to recompress it back to exe form, not an SFX archive.
I can't find an internet solution for my problem, all of the posts I look at talk about recompressing to an SFX file, which I do not want to do, I want to convert it to a fully working exe.
I think you are looking for IExpress.exe: https://www.maketecheasier.com/create-self-extracting-archives-without-installing-software/
Modifying a binary file without breaking it requires a knowledge of hex or assembly. You can't just decompress and compress it back.
How ever there are tools that has ability to make some minor changes to an exe file. This one is an example. Those tools can only alter exe file's resources like icons, some of the texts, images etc.
Hope this helped.

zipx with xz compression(95)

When using zipx with xz, zip format will be same, only compression method changes to 5F, right?
But my doubt is, when i want to compress a folder with multiple file, how does zip do it using xz? Because, xz only supports to compress one single file..
So winzip might have to do some operation to make the folder and its contents to a single file (operation like tar or cpio)
So what METHOD does it use to archieve all the files into a single one?
We tried to zip the folder with no compression to make it to one file, and apply xz on that, but we need to unzip twice to get the orginal folder.
How does zipx do it in one unzip?
The zip file format compresses each file individually. So it can use xz for that, no problem, which compresses one file. The zip format is individual file compression followed by archiving. Things like .tar.gz or .tar.xz are the opposite, which is archiving followed by compression of the entire archive.

compare catalog and compressed catalog (is there new changes)

I want to compare catalog with compressed without extracting or compress files and compare. Is there any way to compare directory with compressed directory ?
Example:
I have some files in tmpfs (ramdisk), before server shutdown, I need to save files to disk. In my opinion best way is compress files and save to disk like a file. On start server (system) I want to decompress files in to the ramdisk. But after couple days ramdisk files will be updated (different with compress file backup).
How to compare and merge diff ?
Regards,
Nerus.
Executing:
tar -tvf foo.tar.gz
will show the contents of the compressed file without decompressing. You can then compare the files.

Creating customized .dmg files upon download

I want to distribute a cross-platform application for which the executable file is slightly different, depending on the user who downloaded it. This is done by having a placeholder string somewhere in the executable that is replaced with something user-specific upon download.
The webserver that has to do these string replacements is a Linux machine. For Windows, the executable is not compressed in the installer .exe, so the string replacement is easy.
For uncompressed Mac OS X .dmg files, this is also easy. However, .dmg files that are compressed with either gzip or bzip2 are not so easy. For example, in the latter case, the compressed .dmg is not one big bzip2-compressed disk image, but instead consists of a few different bzip2-compressed parts (with different block sizes) and a plist suffix. Also, decompressing and recompressing the different parts with bzip2 does not result in the original data, so I'm guessing Apple uses some different parameters to bzip2 than the command-line tool.
Is there a way to generate a compressed .dmg from an uncompressed one on Linux (which does not have hdiutil)? Or maybe another suggestion for creating customized applications without pregenerating them? It should work without any input by the user.
I realize that I'm a bit too late here, but we wanted to do exactly the same thing and got it to work using libdmg. https://github.com/planetbeing/libdmg-hfsplus
Basically, you can use libdmg to unpack a dmg file to an uncompressed file containing a hfs+ file system, play around with the files inside the hfs+ file system, and them put it back together again as a dmg file with the correct checksums.
If you use any fancy dmg features, like showing an EULA before the image is mounted, then these will not survive the process. Background images and so on work, though.
If your web server and client support the gzip encoding, then you can deal with uncompressed files on the server, but have them compressed / decompressed on the fly by the web server / web client respectively.
e.g. apache's mod_gzip.
Otherwise maybe you can split your dmg into 3 parts:
the stuff before what you want to replace
the string you want to replace
the stuff after what you want to replace
If the gzip stream is splittable at those points, you could just concatenate the front and back onto the gzipped string you want to replace. That would let you generate it on the fly.
Release a normal, read-only, compressed dmg. Then bundle your app in a package installer with a pre-flight script that sets the variables you need.

Resources