PreviewImage: Remove PNG support (to clean dependencies)
Build Packages / build:rpm (ubuntu2404_nocuda) (push) Successful in 11m13s
Build Packages / build:rpm (ubuntu2204_nocuda) (push) Successful in 12m37s
Build Packages / build:rpm (rocky8) (push) Successful in 12m38s
Build Packages / Generate python client (push) Successful in 15s
Build Packages / build:rpm (rocky8_nocuda) (push) Successful in 13m1s
Build Packages / Create release (push) Has been skipped
Build Packages / build:rpm (rocky8_sls9) (push) Successful in 12m57s
Build Packages / build:rpm (ubuntu2204) (push) Successful in 13m2s
Build Packages / Build documentation (push) Successful in 34s
Build Packages / build:rpm (rocky9_nocuda) (push) Successful in 13m34s
Build Packages / build:rpm (rocky9) (push) Successful in 14m12s
Build Packages / build:rpm (ubuntu2404) (push) Successful in 7m17s
Build Packages / Unit tests (push) Successful in 53m11s
Build Packages / build:rpm (ubuntu2404_nocuda) (push) Successful in 11m13s
Build Packages / build:rpm (ubuntu2204_nocuda) (push) Successful in 12m37s
Build Packages / build:rpm (rocky8) (push) Successful in 12m38s
Build Packages / Generate python client (push) Successful in 15s
Build Packages / build:rpm (rocky8_nocuda) (push) Successful in 13m1s
Build Packages / Create release (push) Has been skipped
Build Packages / build:rpm (rocky8_sls9) (push) Successful in 12m57s
Build Packages / build:rpm (ubuntu2204) (push) Successful in 13m2s
Build Packages / Build documentation (push) Successful in 34s
Build Packages / build:rpm (rocky9_nocuda) (push) Successful in 13m34s
Build Packages / build:rpm (rocky9) (push) Successful in 14m12s
Build Packages / build:rpm (ubuntu2404) (push) Successful in 7m17s
Build Packages / Unit tests (push) Successful in 53m11s
This commit is contained in:
+1
-14
@@ -47,12 +47,6 @@ SET(lzma OFF)
|
||||
SET(jpeg OFF)
|
||||
SET(old-jpeg OFF)
|
||||
|
||||
# PNG
|
||||
set(PNG_SHARED OFF)
|
||||
set(PNG_STATIC ON)
|
||||
set(PNG_EXECUTABLES OFF)
|
||||
set(PNG_TESTS OFF)
|
||||
|
||||
INCLUDE(CheckLanguage)
|
||||
INCLUDE(CheckIncludeFile)
|
||||
CHECK_LANGUAGE(CUDA)
|
||||
@@ -99,13 +93,6 @@ FetchContent_Declare(tiff
|
||||
GIT_TAG v4.6.0
|
||||
EXCLUDE_FROM_ALL)
|
||||
|
||||
FetchContent_Declare(
|
||||
png
|
||||
GIT_REPOSITORY https://github.com/pnggroup/libpng
|
||||
GIT_TAG v1.6.49
|
||||
EXCLUDE_FROM_ALL
|
||||
)
|
||||
|
||||
FetchContent_Declare(hdf5
|
||||
GIT_REPOSITORY https://github.com/HDFGroup/hdf5/
|
||||
GIT_TAG hdf5_1.14.5
|
||||
@@ -149,7 +136,7 @@ FetchContent_Declare(
|
||||
EXCLUDE_FROM_ALL
|
||||
)
|
||||
|
||||
FetchContent_MakeAvailable(pistache_http zstd sls_detector_package catch2 hdf5 tiff png)
|
||||
FetchContent_MakeAvailable(pistache_http zstd sls_detector_package catch2 hdf5 tiff)
|
||||
|
||||
ADD_SUBDIRECTORY(jungfrau)
|
||||
ADD_SUBDIRECTORY(compression)
|
||||
|
||||
@@ -497,35 +497,6 @@ void JFJochBrokerHttp::image_buffer_image_jpeg_get(const std::optional<int64_t>
|
||||
response.send(Pistache::Http::Code::Not_Found);
|
||||
}
|
||||
|
||||
void JFJochBrokerHttp::image_buffer_image_png_get(const std::optional<int64_t> &id,
|
||||
const std::optional<bool> &showUserMask,
|
||||
const std::optional<bool> &showRoi,
|
||||
const std::optional<bool> &showSpots,
|
||||
const std::optional<bool> &showBeamCenter,
|
||||
const std::optional<float> &saturation,
|
||||
const std::optional<int64_t> &jpegQuality,
|
||||
const std::optional<float> &showResRing,
|
||||
const std::optional<std::string> &color,
|
||||
Pistache::Http::ResponseWriter &response) {
|
||||
int64_t image_id = id.value_or(ImageBuffer::MaxImage);
|
||||
PreviewImageSettings settings{};
|
||||
|
||||
settings.show_user_mask = showUserMask.value_or(true);
|
||||
settings.show_roi = showRoi.value_or(false);
|
||||
settings.show_spots = showSpots.value_or(true);
|
||||
settings.saturation_value = saturation.value_or(10);
|
||||
settings.jpeg_quality = jpegQuality.value_or(100);
|
||||
settings.resolution_ring = showResRing;
|
||||
settings.scale = ConvertColorScale(color);
|
||||
settings.show_beam_center = showBeamCenter.value_or(true);
|
||||
settings.format = PreviewImageFormat::PNG;
|
||||
std::string s = state_machine.GetPreviewJPEG(settings, image_id);
|
||||
if (!s.empty())
|
||||
response.send(Pistache::Http::Code::Ok, s, Pistache::Http::Mime::MediaType::fromString("image/jpeg"));
|
||||
else
|
||||
response.send(Pistache::Http::Code::Not_Found);
|
||||
}
|
||||
|
||||
void
|
||||
JFJochBrokerHttp::image_buffer_image_tiff_get(const std::optional<int64_t> &id, Pistache::Http::ResponseWriter &response) {
|
||||
int64_t image_id = ImageBuffer::MaxImage;
|
||||
|
||||
@@ -157,16 +157,6 @@ class JFJochBrokerHttp : public org::openapitools::server::api::DefaultApi {
|
||||
const std::optional<float> &showResRing,
|
||||
const std::optional<std::string> &color,
|
||||
Pistache::Http::ResponseWriter &response) override;
|
||||
void image_buffer_image_png_get(const std::optional<int64_t> &id,
|
||||
const std::optional<bool> &showUserMask,
|
||||
const std::optional<bool> &showRoi,
|
||||
const std::optional<bool> &showSpots,
|
||||
const std::optional<bool> &showBeamCenter,
|
||||
const std::optional<float> &saturation,
|
||||
const std::optional<int64_t> &jpegQuality,
|
||||
const std::optional<float> &showResRing,
|
||||
const std::optional<std::string> &color,
|
||||
Pistache::Http::ResponseWriter &response) override;
|
||||
|
||||
void image_buffer_image_tiff_get(const std::optional<int64_t> &id, Pistache::Http::ResponseWriter &response) override;
|
||||
|
||||
|
||||
@@ -72,7 +72,6 @@ void DefaultApi::setupRoutes() {
|
||||
Routes::Post(*router, base + "/image_buffer/clear", Routes::bind(&DefaultApi::image_buffer_clear_post_handler, this));
|
||||
Routes::Get(*router, base + "/image_buffer/image.cbor", Routes::bind(&DefaultApi::image_buffer_image_cbor_get_handler, this));
|
||||
Routes::Get(*router, base + "/image_buffer/image.jpeg", Routes::bind(&DefaultApi::image_buffer_image_jpeg_get_handler, this));
|
||||
Routes::Get(*router, base + "/image_buffer/image.png", Routes::bind(&DefaultApi::image_buffer_image_png_get_handler, this));
|
||||
Routes::Get(*router, base + "/image_buffer/image.tiff", Routes::bind(&DefaultApi::image_buffer_image_tiff_get_handler, this));
|
||||
Routes::Get(*router, base + "/image_buffer/start.cbor", Routes::bind(&DefaultApi::image_buffer_start_cbor_get_handler, this));
|
||||
Routes::Get(*router, base + "/image_buffer/status", Routes::bind(&DefaultApi::image_buffer_status_get_handler, this));
|
||||
@@ -1078,99 +1077,6 @@ void DefaultApi::image_buffer_image_jpeg_get_handler(const Pistache::Rest::Reque
|
||||
response.send(Pistache::Http::Code::Internal_Server_Error, e.what());
|
||||
}
|
||||
|
||||
}
|
||||
void DefaultApi::image_buffer_image_png_get_handler(const Pistache::Rest::Request &request, Pistache::Http::ResponseWriter response) {
|
||||
try {
|
||||
|
||||
|
||||
// Getting the query params
|
||||
auto idQuery = request.query().get("id");
|
||||
std::optional<int64_t> id;
|
||||
if(idQuery.has_value()){
|
||||
int64_t valueQuery_instance;
|
||||
if(fromStringValue(idQuery.value(), valueQuery_instance)){
|
||||
id = valueQuery_instance;
|
||||
}
|
||||
}
|
||||
auto showUserMaskQuery = request.query().get("show_user_mask");
|
||||
std::optional<bool> showUserMask;
|
||||
if(showUserMaskQuery.has_value()){
|
||||
bool valueQuery_instance;
|
||||
if(fromStringValue(showUserMaskQuery.value(), valueQuery_instance)){
|
||||
showUserMask = valueQuery_instance;
|
||||
}
|
||||
}
|
||||
auto showRoiQuery = request.query().get("show_roi");
|
||||
std::optional<bool> showRoi;
|
||||
if(showRoiQuery.has_value()){
|
||||
bool valueQuery_instance;
|
||||
if(fromStringValue(showRoiQuery.value(), valueQuery_instance)){
|
||||
showRoi = valueQuery_instance;
|
||||
}
|
||||
}
|
||||
auto showSpotsQuery = request.query().get("show_spots");
|
||||
std::optional<bool> showSpots;
|
||||
if(showSpotsQuery.has_value()){
|
||||
bool valueQuery_instance;
|
||||
if(fromStringValue(showSpotsQuery.value(), valueQuery_instance)){
|
||||
showSpots = valueQuery_instance;
|
||||
}
|
||||
}
|
||||
auto showBeamCenterQuery = request.query().get("show_beam_center");
|
||||
std::optional<bool> showBeamCenter;
|
||||
if(showBeamCenterQuery.has_value()){
|
||||
bool valueQuery_instance;
|
||||
if(fromStringValue(showBeamCenterQuery.value(), valueQuery_instance)){
|
||||
showBeamCenter = valueQuery_instance;
|
||||
}
|
||||
}
|
||||
auto saturationQuery = request.query().get("saturation");
|
||||
std::optional<float> saturation;
|
||||
if(saturationQuery.has_value()){
|
||||
float valueQuery_instance;
|
||||
if(fromStringValue(saturationQuery.value(), valueQuery_instance)){
|
||||
saturation = valueQuery_instance;
|
||||
}
|
||||
}
|
||||
auto jpegQualityQuery = request.query().get("jpeg_quality");
|
||||
std::optional<int64_t> jpegQuality;
|
||||
if(jpegQualityQuery.has_value()){
|
||||
int64_t valueQuery_instance;
|
||||
if(fromStringValue(jpegQualityQuery.value(), valueQuery_instance)){
|
||||
jpegQuality = valueQuery_instance;
|
||||
}
|
||||
}
|
||||
auto showResRingQuery = request.query().get("show_res_ring");
|
||||
std::optional<float> showResRing;
|
||||
if(showResRingQuery.has_value()){
|
||||
float valueQuery_instance;
|
||||
if(fromStringValue(showResRingQuery.value(), valueQuery_instance)){
|
||||
showResRing = valueQuery_instance;
|
||||
}
|
||||
}
|
||||
auto colorQuery = request.query().get("color");
|
||||
std::optional<std::string> color;
|
||||
if(colorQuery.has_value()){
|
||||
std::string valueQuery_instance;
|
||||
if(fromStringValue(colorQuery.value(), valueQuery_instance)){
|
||||
color = valueQuery_instance;
|
||||
}
|
||||
}
|
||||
|
||||
try {
|
||||
this->image_buffer_image_png_get(id, showUserMask, showRoi, showSpots, showBeamCenter, saturation, jpegQuality, showResRing, color, response);
|
||||
} catch (Pistache::Http::HttpError &e) {
|
||||
response.send(static_cast<Pistache::Http::Code>(e.code()), e.what());
|
||||
return;
|
||||
} catch (std::exception &e) {
|
||||
this->handleOperationException(e, response);
|
||||
return;
|
||||
}
|
||||
|
||||
} catch (std::exception &e) {
|
||||
response.send(Pistache::Http::Code::Internal_Server_Error, e.what());
|
||||
}
|
||||
|
||||
}
|
||||
void DefaultApi::image_buffer_image_tiff_get_handler(const Pistache::Rest::Request &request, Pistache::Http::ResponseWriter response) {
|
||||
try {
|
||||
|
||||
@@ -107,7 +107,6 @@ private:
|
||||
void image_buffer_clear_post_handler(const Pistache::Rest::Request &request, Pistache::Http::ResponseWriter response);
|
||||
void image_buffer_image_cbor_get_handler(const Pistache::Rest::Request &request, Pistache::Http::ResponseWriter response);
|
||||
void image_buffer_image_jpeg_get_handler(const Pistache::Rest::Request &request, Pistache::Http::ResponseWriter response);
|
||||
void image_buffer_image_png_get_handler(const Pistache::Rest::Request &request, Pistache::Http::ResponseWriter response);
|
||||
void image_buffer_image_tiff_get_handler(const Pistache::Rest::Request &request, Pistache::Http::ResponseWriter response);
|
||||
void image_buffer_start_cbor_get_handler(const Pistache::Rest::Request &request, Pistache::Http::ResponseWriter response);
|
||||
void image_buffer_status_get_handler(const Pistache::Rest::Request &request, Pistache::Http::ResponseWriter response);
|
||||
@@ -451,22 +450,6 @@ private:
|
||||
/// <param name="color">Color scale for preview image: 0 - indigo, 1 - viridis, 2 - B/W, 3 - heat (optional, default to "indigo")</param>
|
||||
virtual void image_buffer_image_jpeg_get(const std::optional<int64_t> &id, const std::optional<bool> &showUserMask, const std::optional<bool> &showRoi, const std::optional<bool> &showSpots, const std::optional<bool> &showBeamCenter, const std::optional<float> &saturation, const std::optional<int64_t> &jpegQuality, const std::optional<float> &showResRing, const std::optional<std::string> &color, Pistache::Http::ResponseWriter &response) = 0;
|
||||
/// <summary>
|
||||
/// Get preview image in PNG format using custom settings
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
///
|
||||
/// </remarks>
|
||||
/// <param name="id">Image ID in the image buffer. Special values: -1 - last image in the buffer, -2: last indexed image in the buffer (optional, default to -1L)</param>
|
||||
/// <param name="showUserMask">Show user mask (optional, default to false)</param>
|
||||
/// <param name="showRoi">Show ROI areas on the image (optional, default to false)</param>
|
||||
/// <param name="showSpots">Show spot finding results on the image (optional, default to true)</param>
|
||||
/// <param name="showBeamCenter">Show beam center on the image (optional, default to true)</param>
|
||||
/// <param name="saturation">Saturation value to set contrast in the preview image (optional, default to 10.0f)</param>
|
||||
/// <param name="jpegQuality">Quality of JPEG image (100 - highest; 0 - lowest) (optional, default to 100L)</param>
|
||||
/// <param name="showResRing">Show resolution ring, provided in Angstrom (optional, default to 0.1f)</param>
|
||||
/// <param name="color">Color scale for preview image: 0 - indigo, 1 - viridis, 2 - B/W, 3 - heat (optional, default to "indigo")</param>
|
||||
virtual void image_buffer_image_png_get(const std::optional<int64_t> &id, const std::optional<bool> &showUserMask, const std::optional<bool> &showRoi, const std::optional<bool> &showSpots, const std::optional<bool> &showBeamCenter, const std::optional<float> &saturation, const std::optional<int64_t> &jpegQuality, const std::optional<float> &showResRing, const std::optional<std::string> &color, Pistache::Http::ResponseWriter &response) = 0;
|
||||
/// <summary>
|
||||
/// Get preview image in TIFF format
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
|
||||
@@ -3103,42 +3103,6 @@ paths:
|
||||
application/json:
|
||||
schema:
|
||||
$ref: '#/components/schemas/error_message'
|
||||
/image_buffer/image.png:
|
||||
get:
|
||||
summary: Get preview image in PNG format using custom settings
|
||||
parameters:
|
||||
- $ref: '#/components/parameters/image_id'
|
||||
- $ref: '#/components/parameters/show_user_mask'
|
||||
- $ref: '#/components/parameters/show_roi'
|
||||
- $ref: '#/components/parameters/show_spots'
|
||||
- $ref: '#/components/parameters/show_beam_center'
|
||||
- $ref: '#/components/parameters/saturation'
|
||||
- $ref: '#/components/parameters/jpeg_quality'
|
||||
- $ref: '#/components/parameters/resolution_ring'
|
||||
- $ref: '#/components/parameters/color_scale'
|
||||
responses:
|
||||
"200":
|
||||
description: Preview image
|
||||
content:
|
||||
image/jpeg:
|
||||
schema:
|
||||
type: string
|
||||
format: binary
|
||||
"404":
|
||||
description: Image not present in the buffer - either not yet measured or already replaced by a next image.
|
||||
"400":
|
||||
description: Input parsing or validation error
|
||||
content:
|
||||
text/plain:
|
||||
schema:
|
||||
type: string
|
||||
description: Exception error
|
||||
"500":
|
||||
description: Error within Jungfraujoch code - see output message.
|
||||
content:
|
||||
application/json:
|
||||
schema:
|
||||
$ref: '#/components/schemas/error_message'
|
||||
/image_buffer/image.tiff:
|
||||
get:
|
||||
summary: Get preview image in TIFF format
|
||||
|
||||
File diff suppressed because one or more lines are too long
@@ -29,7 +29,6 @@ RUN dnf -y update && \
|
||||
rpm-build \
|
||||
rpmdevtools \
|
||||
numactl-devel \
|
||||
openssl-devel \
|
||||
redhat-rpm-config \
|
||||
ninja-build \
|
||||
libxcb-devel \
|
||||
@@ -65,6 +64,7 @@ RUN dnf -y update && \
|
||||
python3-wheel \
|
||||
twine \
|
||||
openblas \
|
||||
openblas-static \
|
||||
openblas-devel \
|
||||
libdrm-devel \
|
||||
libglvnd-core-devel \
|
||||
|
||||
@@ -57,6 +57,7 @@ RUN dnf -y update && \
|
||||
zlib-static \
|
||||
fontconfig-devel \
|
||||
openblas-devel \
|
||||
openblas-static \
|
||||
openblas-serial \
|
||||
mesa-dri-drivers \
|
||||
libdrm-devel \
|
||||
|
||||
@@ -31,6 +31,7 @@ Automatically downloaded by CMake and statically linked:
|
||||
* Catch2 testing library - see [github.com/catchorg/Catch2](https://github.com/catchorg/Catch2)
|
||||
* HDF5 library - see [github.com/HDFGroup/hdf5](https://github.com/HDFGroup/hdf5)
|
||||
* TIFF library - see [gitlab.com/libtiff/libtiff](https://gitlab.com/libtiff/libtiff)
|
||||
* JPEG library (preferably jpeg-turbo) - see [github.com/libjpeg-turbo/libjpeg-turbo](https://github.com/libjpeg-turbo/libjpeg-turbo)
|
||||
* Ceres Solver library for least square optimization - see [http://ceres-solver.org/]
|
||||
|
||||
Please follow the link provided above to check for LICENSE file. Building code with dependencies above requires access from the build system to github.com.
|
||||
|
||||
@@ -140,7 +140,6 @@ Class | Method | HTTP request | Description
|
||||
*DefaultApi* | [**image_buffer_clear_post**](docs/DefaultApi.md#image_buffer_clear_post) | **POST** /image_buffer/clear | Clear image buffer
|
||||
*DefaultApi* | [**image_buffer_image_cbor_get**](docs/DefaultApi.md#image_buffer_image_cbor_get) | **GET** /image_buffer/image.cbor | Get image message in CBOR format
|
||||
*DefaultApi* | [**image_buffer_image_jpeg_get**](docs/DefaultApi.md#image_buffer_image_jpeg_get) | **GET** /image_buffer/image.jpeg | Get preview image in JPEG format using custom settings
|
||||
*DefaultApi* | [**image_buffer_image_png_get**](docs/DefaultApi.md#image_buffer_image_png_get) | **GET** /image_buffer/image.png | Get preview image in PNG format using custom settings
|
||||
*DefaultApi* | [**image_buffer_image_tiff_get**](docs/DefaultApi.md#image_buffer_image_tiff_get) | **GET** /image_buffer/image.tiff | Get preview image in TIFF format
|
||||
*DefaultApi* | [**image_buffer_start_cbor_get**](docs/DefaultApi.md#image_buffer_start_cbor_get) | **GET** /image_buffer/start.cbor | Get Start message in CBOR format
|
||||
*DefaultApi* | [**image_buffer_status_get**](docs/DefaultApi.md#image_buffer_status_get) | **GET** /image_buffer/status | Get status of the image buffers
|
||||
|
||||
@@ -43,7 +43,6 @@ Method | HTTP request | Description
|
||||
[**image_buffer_clear_post**](DefaultApi.md#image_buffer_clear_post) | **POST** /image_buffer/clear | Clear image buffer
|
||||
[**image_buffer_image_cbor_get**](DefaultApi.md#image_buffer_image_cbor_get) | **GET** /image_buffer/image.cbor | Get image message in CBOR format
|
||||
[**image_buffer_image_jpeg_get**](DefaultApi.md#image_buffer_image_jpeg_get) | **GET** /image_buffer/image.jpeg | Get preview image in JPEG format using custom settings
|
||||
[**image_buffer_image_png_get**](DefaultApi.md#image_buffer_image_png_get) | **GET** /image_buffer/image.png | Get preview image in PNG format using custom settings
|
||||
[**image_buffer_image_tiff_get**](DefaultApi.md#image_buffer_image_tiff_get) | **GET** /image_buffer/image.tiff | Get preview image in TIFF format
|
||||
[**image_buffer_start_cbor_get**](DefaultApi.md#image_buffer_start_cbor_get) | **GET** /image_buffer/start.cbor | Get Start message in CBOR format
|
||||
[**image_buffer_status_get**](DefaultApi.md#image_buffer_status_get) | **GET** /image_buffer/status | Get status of the image buffers
|
||||
@@ -2578,90 +2577,6 @@ with jfjoch_client.ApiClient(configuration) as api_client:
|
||||
|
||||
|
||||
|
||||
### Parameters
|
||||
|
||||
|
||||
Name | Type | Description | Notes
|
||||
------------- | ------------- | ------------- | -------------
|
||||
**id** | **int**| Image ID in the image buffer. Special values: -1 - last image in the buffer, -2: last indexed image in the buffer | [optional] [default to -1]
|
||||
**show_user_mask** | **bool**| Show user mask | [optional] [default to False]
|
||||
**show_roi** | **bool**| Show ROI areas on the image | [optional] [default to False]
|
||||
**show_spots** | **bool**| Show spot finding results on the image | [optional] [default to True]
|
||||
**show_beam_center** | **bool**| Show beam center on the image | [optional] [default to True]
|
||||
**saturation** | **float**| Saturation value to set contrast in the preview image | [optional] [default to 10]
|
||||
**jpeg_quality** | **int**| Quality of JPEG image (100 - highest; 0 - lowest) | [optional] [default to 100]
|
||||
**show_res_ring** | **float**| Show resolution ring, provided in Angstrom | [optional] [default to 0.1]
|
||||
**color** | **str**| Color scale for preview image: 0 - indigo, 1 - viridis, 2 - B/W, 3 - heat | [optional] [default to indigo]
|
||||
|
||||
### Return type
|
||||
|
||||
**bytearray**
|
||||
|
||||
### Authorization
|
||||
|
||||
No authorization required
|
||||
|
||||
### HTTP request headers
|
||||
|
||||
- **Content-Type**: Not defined
|
||||
- **Accept**: image/jpeg, text/plain, application/json
|
||||
|
||||
### HTTP response details
|
||||
|
||||
| Status code | Description | Response headers |
|
||||
|-------------|-------------|------------------|
|
||||
**200** | Preview image | - |
|
||||
**404** | Image not present in the buffer - either not yet measured or already replaced by a next image. | - |
|
||||
**400** | Input parsing or validation error | - |
|
||||
**500** | Error within Jungfraujoch code - see output message. | - |
|
||||
|
||||
[[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md)
|
||||
|
||||
# **image_buffer_image_png_get**
|
||||
> bytearray image_buffer_image_png_get(id=id, show_user_mask=show_user_mask, show_roi=show_roi, show_spots=show_spots, show_beam_center=show_beam_center, saturation=saturation, jpeg_quality=jpeg_quality, show_res_ring=show_res_ring, color=color)
|
||||
|
||||
Get preview image in PNG format using custom settings
|
||||
|
||||
### Example
|
||||
|
||||
|
||||
```python
|
||||
import jfjoch_client
|
||||
from jfjoch_client.rest import ApiException
|
||||
from pprint import pprint
|
||||
|
||||
# Defining the host is optional and defaults to http://localhost:5232
|
||||
# See configuration.py for a list of all supported configuration parameters.
|
||||
configuration = jfjoch_client.Configuration(
|
||||
host = "http://localhost:5232"
|
||||
)
|
||||
|
||||
|
||||
# Enter a context with an instance of the API client
|
||||
with jfjoch_client.ApiClient(configuration) as api_client:
|
||||
# Create an instance of the API class
|
||||
api_instance = jfjoch_client.DefaultApi(api_client)
|
||||
id = -1 # int | Image ID in the image buffer. Special values: -1 - last image in the buffer, -2: last indexed image in the buffer (optional) (default to -1)
|
||||
show_user_mask = False # bool | Show user mask (optional) (default to False)
|
||||
show_roi = False # bool | Show ROI areas on the image (optional) (default to False)
|
||||
show_spots = True # bool | Show spot finding results on the image (optional) (default to True)
|
||||
show_beam_center = True # bool | Show beam center on the image (optional) (default to True)
|
||||
saturation = 10 # float | Saturation value to set contrast in the preview image (optional) (default to 10)
|
||||
jpeg_quality = 100 # int | Quality of JPEG image (100 - highest; 0 - lowest) (optional) (default to 100)
|
||||
show_res_ring = 0.1 # float | Show resolution ring, provided in Angstrom (optional) (default to 0.1)
|
||||
color = indigo # str | Color scale for preview image: 0 - indigo, 1 - viridis, 2 - B/W, 3 - heat (optional) (default to indigo)
|
||||
|
||||
try:
|
||||
# Get preview image in PNG format using custom settings
|
||||
api_response = api_instance.image_buffer_image_png_get(id=id, show_user_mask=show_user_mask, show_roi=show_roi, show_spots=show_spots, show_beam_center=show_beam_center, saturation=saturation, jpeg_quality=jpeg_quality, show_res_ring=show_res_ring, color=color)
|
||||
print("The response of DefaultApi->image_buffer_image_png_get:\n")
|
||||
pprint(api_response)
|
||||
except Exception as e:
|
||||
print("Exception when calling DefaultApi->image_buffer_image_png_get: %s\n" % e)
|
||||
```
|
||||
|
||||
|
||||
|
||||
### Parameters
|
||||
|
||||
|
||||
|
||||
Generated
+2
-2
@@ -1,12 +1,12 @@
|
||||
{
|
||||
"name": "jungfraujoch-frontend",
|
||||
"version": "1.0.0-rc.94",
|
||||
"version": "1.0.0-rc.95",
|
||||
"lockfileVersion": 3,
|
||||
"requires": true,
|
||||
"packages": {
|
||||
"": {
|
||||
"name": "jungfraujoch-frontend",
|
||||
"version": "1.0.0-rc.94",
|
||||
"version": "1.0.0-rc.95",
|
||||
"license": "GPL-3.0",
|
||||
"dependencies": {
|
||||
"@emotion/react": "^11.10.4",
|
||||
|
||||
@@ -27,7 +27,6 @@ type preview_settings = {
|
||||
resolution_ring: number;
|
||||
scale: color_scale;
|
||||
image_id: number;
|
||||
use_png: boolean;
|
||||
};
|
||||
|
||||
type MyProps = {
|
||||
@@ -76,8 +75,7 @@ class PreviewImage extends Component<MyProps, MyState> {
|
||||
show_beam_center: true,
|
||||
resolution_ring: 0.5,
|
||||
scale: color_scale.INDIGO,
|
||||
image_id: -1,
|
||||
use_png: true
|
||||
image_id: -1
|
||||
},
|
||||
s_url: null,
|
||||
update: true,
|
||||
@@ -158,15 +156,6 @@ class PreviewImage extends Component<MyProps, MyState> {
|
||||
this.getValues(s);
|
||||
}
|
||||
|
||||
usePNGToggle = (event: React.ChangeEvent<HTMLInputElement>) => {
|
||||
let s : preview_settings = {
|
||||
...this.state.settings,
|
||||
use_png: event.target.checked
|
||||
};
|
||||
this.setState({settings: s});
|
||||
this.getValues(s);
|
||||
}
|
||||
|
||||
showBeamCenterToggle = (event: React.ChangeEvent<HTMLInputElement>) => {
|
||||
let s : preview_settings = {
|
||||
...this.state.settings,
|
||||
@@ -246,13 +235,7 @@ class PreviewImage extends Component<MyProps, MyState> {
|
||||
}
|
||||
|
||||
getImage(s: preview_settings,) {
|
||||
let url = `/image_buffer/image.`;
|
||||
|
||||
if (s.use_png)
|
||||
url += "png";
|
||||
else
|
||||
url += "jpeg";
|
||||
|
||||
let url = `/image_buffer/image.jpeg`;
|
||||
url += `?id=${s.image_id}`;
|
||||
url += `&saturation=${s.saturation}`;
|
||||
url += `&jpeg_quality=${s.jpeg_quality}`
|
||||
@@ -360,9 +343,6 @@ class PreviewImage extends Component<MyProps, MyState> {
|
||||
<FormControlLabel control={
|
||||
<Checkbox checked={this.state.update} onChange={this.updateToggle} name="Update"/>
|
||||
} label="Auto-update image"/>
|
||||
<FormControlLabel control={
|
||||
<Checkbox checked={this.state.settings.use_png} onChange={this.usePNGToggle} name="Use PNG format"/>
|
||||
} label="PNG image format (slower, but lossless)"/>
|
||||
<FormControlLabel control={
|
||||
<Checkbox checked={this.state.settings.show_spots} onChange={this.showSpotsToggle} name="Show spots"/>
|
||||
} label="Show spots"/>
|
||||
|
||||
@@ -1081,53 +1081,6 @@ export class DefaultService {
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Get preview image in PNG format using custom settings
|
||||
* @param id Image ID in the image buffer. Special values: -1 - last image in the buffer, -2: last indexed image in the buffer
|
||||
* @param showUserMask Show user mask
|
||||
* @param showRoi Show ROI areas on the image
|
||||
* @param showSpots Show spot finding results on the image
|
||||
* @param showBeamCenter Show beam center on the image
|
||||
* @param saturation Saturation value to set contrast in the preview image
|
||||
* @param jpegQuality Quality of JPEG image (100 - highest; 0 - lowest)
|
||||
* @param showResRing Show resolution ring, provided in Angstrom
|
||||
* @param color Color scale for preview image: 0 - indigo, 1 - viridis, 2 - B/W, 3 - heat
|
||||
* @returns binary Preview image
|
||||
* @throws ApiError
|
||||
*/
|
||||
public static getImageBufferImagePng(
|
||||
id: number = -1,
|
||||
showUserMask: boolean = false,
|
||||
showRoi: boolean = false,
|
||||
showSpots: boolean = true,
|
||||
showBeamCenter: boolean = true,
|
||||
saturation: number = 10,
|
||||
jpegQuality: number = 100,
|
||||
showResRing: number = 0.1,
|
||||
color: 'indigo' | 'viridis' | 'bw' | 'heat' = 'indigo',
|
||||
): CancelablePromise<Blob> {
|
||||
return __request(OpenAPI, {
|
||||
method: 'GET',
|
||||
url: '/image_buffer/image.png',
|
||||
query: {
|
||||
'id': id,
|
||||
'show_user_mask': showUserMask,
|
||||
'show_roi': showRoi,
|
||||
'show_spots': showSpots,
|
||||
'show_beam_center': showBeamCenter,
|
||||
'saturation': saturation,
|
||||
'jpeg_quality': jpegQuality,
|
||||
'show_res_ring': showResRing,
|
||||
'color': color,
|
||||
},
|
||||
errors: {
|
||||
400: `Input parsing or validation error`,
|
||||
404: `Image not present in the buffer - either not yet measured or already replaced by a next image.`,
|
||||
500: `Error within Jungfraujoch code - see output message.`,
|
||||
},
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Get preview image in TIFF format
|
||||
* @param id Image ID in the image buffer. Special values: -1 - last image in the buffer, -2: last indexed image in the buffer
|
||||
|
||||
@@ -42,8 +42,6 @@ ADD_LIBRARY(JFJochPreview STATIC
|
||||
ZMQPreviewSocket.h
|
||||
ZMQMetadataSocket.cpp
|
||||
ZMQMetadataSocket.h
|
||||
JFJochPNG.cpp
|
||||
JFJochPNG.h
|
||||
)
|
||||
|
||||
TARGET_LINK_LIBRARIES(JFJochPreview PUBLIC JFJochZMQ JFJochCommon CBORStream2FrameSerialize)
|
||||
|
||||
@@ -1,91 +0,0 @@
|
||||
// SPDX-FileCopyrightText: 2025 Filip Leonarski, Paul Scherrer Institute <filip.leonarski@psi.ch>
|
||||
// SPDX-License-Identifier: GPL-3.0-only
|
||||
|
||||
|
||||
#include <vector>
|
||||
#include <cstdint>
|
||||
#include <cmath>
|
||||
#include <png.h>
|
||||
#include <string>
|
||||
#include <cstring>
|
||||
|
||||
#include "../common/JFJochException.h"
|
||||
|
||||
#include "JFJochPNG.h"
|
||||
|
||||
struct PNGMemoryWriter {
|
||||
std::string buffer;
|
||||
};
|
||||
|
||||
void pngWriteCallback(png_structp png_ptr, png_bytep data, png_size_t length) {
|
||||
auto writer = static_cast<PNGMemoryWriter*>(png_get_io_ptr(png_ptr));
|
||||
size_t old_size = writer->buffer.size();
|
||||
writer->buffer.resize(old_size + length);
|
||||
std::memcpy(writer->buffer.data() + old_size, data, length);
|
||||
}
|
||||
|
||||
std::string WritePNGToMem(const CompressedImage& image, int compression_level) {
|
||||
if (image.GetMode() != CompressedImageMode::RGB)
|
||||
throw JFJochException(JFJochExceptionCategory::InputParameterInvalid,
|
||||
"Only RGB images allowed for PNG saving");
|
||||
|
||||
std::vector<uint8_t> buffer;
|
||||
image.GetUncompressed(buffer);
|
||||
|
||||
int width = image.GetWidth();
|
||||
int height = image.GetHeight();
|
||||
int color_type = PNG_COLOR_TYPE_RGB;
|
||||
int bit_depth = 8;
|
||||
|
||||
// Initialize libpng structures
|
||||
png_structp png_ptr = png_create_write_struct(PNG_LIBPNG_VER_STRING,
|
||||
NULL, NULL, NULL);
|
||||
if (!png_ptr) {
|
||||
throw JFJochException(JFJochExceptionCategory::InputParameterInvalid,
|
||||
"Error initializing PNG write structure");
|
||||
}
|
||||
|
||||
png_infop info_ptr = png_create_info_struct(png_ptr);
|
||||
if (!info_ptr) {
|
||||
png_destroy_write_struct(&png_ptr, NULL);
|
||||
throw JFJochException(JFJochExceptionCategory::InputParameterInvalid,
|
||||
"Error initializing PNG info structure");
|
||||
}
|
||||
|
||||
// Set up error handling
|
||||
if (setjmp(png_jmpbuf(png_ptr))) {
|
||||
png_destroy_write_struct(&png_ptr, &info_ptr);
|
||||
throw JFJochException(JFJochExceptionCategory::InputParameterInvalid, "Error during PNG creation");
|
||||
}
|
||||
|
||||
PNGMemoryWriter writer;
|
||||
|
||||
writer.buffer.reserve(width * height * 3);
|
||||
|
||||
png_set_write_fn(png_ptr, &writer, pngWriteCallback, NULL);
|
||||
|
||||
// Set image information
|
||||
png_set_IHDR(png_ptr, info_ptr, width, height, bit_depth, color_type,
|
||||
PNG_INTERLACE_NONE, PNG_COMPRESSION_TYPE_DEFAULT, PNG_FILTER_TYPE_DEFAULT);
|
||||
|
||||
// Set compression level (0-9, where 0 is no compression and 9 is maximum)
|
||||
png_set_compression_level(png_ptr, compression_level);
|
||||
|
||||
// Write PNG header
|
||||
png_write_info(png_ptr, info_ptr);
|
||||
|
||||
// Allocate row pointers
|
||||
std::vector<png_bytep> row_pointers(height);
|
||||
for (int y = 0; y < height; y++) {
|
||||
row_pointers[y] = buffer.data() + y * width * 3;
|
||||
}
|
||||
|
||||
// Write PNG image data
|
||||
png_write_image(png_ptr, row_pointers.data());
|
||||
|
||||
// Finish writing
|
||||
png_write_end(png_ptr, NULL);
|
||||
png_destroy_write_struct(&png_ptr, &info_ptr);
|
||||
|
||||
return writer.buffer;
|
||||
}
|
||||
@@ -1,11 +0,0 @@
|
||||
// SPDX-FileCopyrightText: 2025 Filip Leonarski, Paul Scherrer Institute <filip.leonarski@psi.ch>
|
||||
// SPDX-License-Identifier: GPL-3.0-only
|
||||
|
||||
#ifndef JFJOCH_JFJOCHPNG_H
|
||||
#define JFJOCH_JFJOCHPNG_H
|
||||
|
||||
#include "../common/CompressedImage.h"
|
||||
|
||||
std::string WritePNGToMem(const CompressedImage& image, int compression_level = 6);
|
||||
|
||||
#endif //JFJOCH_JFJOCHPNG_H
|
||||
@@ -11,7 +11,6 @@
|
||||
#include "../common/DiffractionGeometry.h"
|
||||
#include "../frame_serialize/CBORStream2Deserializer.h"
|
||||
#include "../compression/JFJochDecompress.h"
|
||||
#include "JFJochPNG.h"
|
||||
|
||||
constexpr const static rgb lime = {.r = 0xcd, .g = 0xdc, .b = 0x39};
|
||||
constexpr const static rgb pink = {.r = 0xe9, .g = 0x1e, .b = 0x63};
|
||||
@@ -263,8 +262,6 @@ std::string PreviewImage::GenerateImage(const PreviewImageSettings& settings,
|
||||
return WriteJPEGToMem(rgb_image, settings.jpeg_quality);
|
||||
case PreviewImageFormat::TIFF:
|
||||
return WriteTIFFToString(rgb_image);
|
||||
case PreviewImageFormat::PNG:
|
||||
return WritePNGToMem(rgb_image);
|
||||
default:
|
||||
throw JFJochException(JFJochExceptionCategory::InputParameterInvalid,
|
||||
"Preview image format not supported");
|
||||
|
||||
@@ -13,7 +13,7 @@
|
||||
#include "PreviewCounter.h"
|
||||
#include "../common/ColorScale.h"
|
||||
|
||||
enum class PreviewImageFormat {JPEG, PNG, TIFF};
|
||||
enum class PreviewImageFormat {JPEG, TIFF};
|
||||
|
||||
struct PreviewImageSettings {
|
||||
float saturation_value = 10;
|
||||
|
||||
@@ -30,7 +30,6 @@ ADD_EXECUTABLE(jfjoch_test
|
||||
TIFFTest.cpp
|
||||
JFJochReceiverProcessingTest.cpp
|
||||
JPEGTest.cpp
|
||||
PNGTest.cpp
|
||||
HistogramTest.cpp
|
||||
ROIMapTest.cpp
|
||||
LossyFilterTest.cpp
|
||||
|
||||
@@ -1,32 +0,0 @@
|
||||
// SPDX-FileCopyrightText: 2024 Filip Leonarski, Paul Scherrer Institute <filip.leonarski@psi.ch>
|
||||
// SPDX-License-Identifier: GPL-3.0-only
|
||||
|
||||
#include <catch2/catch_all.hpp>
|
||||
|
||||
#include <fstream>
|
||||
#include "../preview/JFJochPNG.h"
|
||||
|
||||
TEST_CASE("PNGTest","[PNG]") {
|
||||
size_t width = 1024;
|
||||
size_t height = 1024;
|
||||
std::vector<rgb> val(width * height);
|
||||
for (int i = 0; i < width * height; i++) {
|
||||
size_t x = i % width;
|
||||
if (x < 512) {
|
||||
val[i].r = 234;
|
||||
val[i].g = 0;
|
||||
val[i].b = 0;
|
||||
} else {
|
||||
val[i].r = 0;
|
||||
val[i].g = 0;
|
||||
val[i].b = 255;
|
||||
}
|
||||
}
|
||||
|
||||
std::string s;
|
||||
|
||||
CompressedImage image(val, width, height);
|
||||
REQUIRE_NOTHROW(s = WritePNGToMem(image));
|
||||
std::ofstream f("x.png", std::ios::binary);
|
||||
f.write(s.data(), s.size());
|
||||
}
|
||||
Reference in New Issue
Block a user