Scheduled service maintenance on November 22


On Friday, November 22, 2024, between 06:00 CET and 18:00 CET, GIN services will undergo planned maintenance. Extended service interruptions should be expected. We will try to keep downtimes to a minimum, but recommend that users avoid critical tasks, large data uploads, or DOI requests during this time.

We apologize for any inconvenience.

zlibencode.m 774 B

123456789101112131415161718192021222324252627
  1. function output = zlibencode(input)
  2. %ZLIBENCODE Compress input bytes with ZLIB.
  3. %
  4. % output = zlibencode(input)
  5. %
  6. % The function takes a char, int8, or uint8 array INPUT and returns
  7. % compressed bytes OUTPUT as a uint8 array. Note that the compression
  8. % doesn't preserve input dimensions. JAVA must be enabled to use the
  9. % function.
  10. %
  11. % See also zlibdecode typecast
  12. error(nargchk(1, 1, nargin));
  13. error(javachk('jvm'));
  14. if ischar(input), input = uint8(input); end
  15. if ~isa(input, 'int8') && ~isa(input, 'uint8')
  16. error('Input must be either char, int8 or uint8.');
  17. end
  18. buffer = java.io.ByteArrayOutputStream();
  19. zlib = java.util.zip.DeflaterOutputStream(buffer);
  20. zlib.write(input, 0, numel(input));
  21. zlib.close();
  22. output = typecast(buffer.toByteArray(), 'uint8')';
  23. end